Seite 8 von 8

Verfasst: Do 25. Okt 2018, 11:34
von TreeNode
Hallo, I‘ve got it working again. This time is it a bit more difficult, because we have to modify the xpi file. Beside that it is simula to the last one. In order to make it simpler I wrote as script, that sets the link, regEntry, the bat File and creates the extensions.rdf file if they don’t exist.

0. install MyPhoneExplorer und Lightning in Thunderbird(xul-ext-lightning)
1. open the MyPhonEexplorer xpi File an copy the mpe.js file (I used xarchiver)
2. open the mpe.js and replace the RegRead and Run function with:

Code: Alles auswählen

function RegRead(subkey,valuename)
{
var out = ''; 
var os = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime).OS; 
if (os=="Linux"||IO.getFile("/usr/bin","wine").exists()){ 
// um die Konstanten zu genierieren
Components.classes["@mozilla.org/net/osfileconstantsservice;1"].getService(Components.interfaces.nsIOSFileConstantsService).init(); 
// erzeuge ein tmp file mit dem inhalt #!/bin/bash \n\$1 \> \$2 um die rückgabe der bash in eine Datei zu schreiben
var copyFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
copyFile.append("copy.sh");
copyFile.createUnique(copyFile.nsIFile.NORMAL_FILE_TYPE, 0o700);
WriteFile(copyFile.path,"#!/bin/bash \n\$1 \> \$2"); 
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.init(copyFile);
var tmpFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
tmpFile.append("Query.tmp");
tmpFile.createUnique(tmpFile.NORMAL_FILE_TYPE, 0o600);
var args = ["wine reg Query HKCU\\"+subkey +" /v "+valuename, tmpFile.path];
process.run(true, args, args.length);
try { 
var out = ReadFile(tmpFile.path);
out=out[2];
out=out.split("REG_SZ ");
out=out[1];
tmpFile.remove(false);
copyFile.remove(false);
//prüft ob es ein Systempfad ist(zweite Stelle ":")
if(out.indexOf(":")==1){ 
out= 'dosdevices/'+out.substr(0,1).toLowerCase()+out.substr(1,out.length-1);
out = out.split('\\').join('/');//ersetzt alle \\ durch /
out=OS.Constants.Path.homeDir+'/.wine/'+out; 
} 
}
catch(ex) {
Components.utils.reportError('Error reading HKCU\\' + subkey + ' : ' + valuename + ' : ' + ex);
} 
}
else{ 
try { 
var wrk = Components.classes["@mozilla.org/windows-registry-key;1"].createInstance(Components.interfaces.nsIWindowsRegKey);
wrk.open(wrk.ROOT_KEY_CURRENT_USER,subkey,wrk.ACCESS_READ);
out = wrk.readStringValue(valuename);
wrk.close(); 
}
catch(ex) {
// Components.utils.reportError('Error reading HKCU\\' + subkey + ' : ' + valuename + ' : ' + ex);
} 
}
//Components.utils.reportError(out);
return(out); 
}


 
Run: function(args)
{
//var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess); 

args=[args];
var os = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime).OS
var path = RegRead("Software\\MyPhoneExplorer", "PathToExe");
if (os=="Linux"||IO.getFile("/usr/bin","wine").exists()){ 
args=[path,args[0]];
path= "/usr/bin/wine"; 
}
if (path.length != 0) { 
try
{ 
//file.initWithPath(path);
var file = new FileUtils.File(path);
process.init(file);
process.run(false, args, args.length);
return; 
}
catch(ex)
{ 
Components.utils.reportError('Could not run ' + path);
return; 
} 
}
Components.utils.reportError("Could not find MyPhoneExplorer.exe"); 
}, 

3. put the modified file back into the xpi (also with xarchiver)
4. install the MyPhoneExplorer-Addon in thunderbird
5. make sure all links and regEntrys and Files are in place or run the script(store it as an executable file)

Code: Alles auswählen

#!/bin/bash
#prüfe ob wine installiert
if [ -f /usr/bin/wine ]; then
	#erzeuge RegEintrag und bat-Datei für Thunderbird
	batfilePath="$HOME/.wine/drive_c/Program Files/Mozilla Thunderbird"
	key="HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\thunderbird.exe"
	data="C:\\Program Files\\Mozilla Thunderbird\\thunderbird.bat"
	wine reg add "$key" /v "" /t REG_SZ /d "$data"
	#erzeuge .bat
	if [ ! -d "$batfilePath" ]; then
		mkdir "$batfilePath"
	fi
	echo "start /unix /usr/bin/thunderbird %1 %2" > "$batfilePath/thunderbird.bat"
	chmod 777 "$batfilePath/thunderbird.bat"

	# erzeuge softlink
	target="$HOME/.thunderbird"
	#aus REG auslesen
	key="HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
	data="AppData"
	position=`wine reg query "$key" /v "$data"`
	index=`expr index "$position"  ':'`
	position="${position:($index-2):(${#position}-$index-1)}"
	if [ "$position" != "" ]; then
		position="${position,}"
		#resetze \ durch /
		position="${position//\\/\/}"

		position="$HOME/.wine/dosdevices/$position/Thunderbird"

		#prüfen ob datei schon existiert
		if [ ! -e "$position" ]; then
			ln -s "$target" "$position"
		fi
	fi
	unset batfilePath
	unset key
	unset data
	unset target
	unset position
	unset index

	#erzeuge extension.rdf

	if [[ $(grep '\[Profile[^0]\]' "$HOME/.thunderbird/profiles.ini") ]]
	 then echo multi user funktioniert noch nicht, schreibe in thunderbird ordner
	else target=$(grep 'Path=' "$HOME/.thunderbird/profiles.ini" | sed 's/^Path=//' | sed 's/\r//' | sed 's/\n//')
	fi
	target="$HOME/.thunderbird/$target/extensions.rdf"
	if [ ! -e "$target" ]; then
	  echo "<?xml version=\"1.0\"?>" > "$target"
	  echo "<RDF:RDF xmlns:NS1=\"http://www.mozilla.org/2004/em-rdf#\"" >> "$target"
	  echo "         xmlns:NC=\"http://home.netscape.com/NC-rdf#\"" >> "$target"
	  echo "         xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">" >> "$target"
	  echo "  <RDF:Seq RDF:about=\"urn:mozilla:item:root\">" >> "$target"
	  echo "    <RDF:li RDF:resource=\"urn:mozilla:item:{e2fda1a4-762b-4020-b5ad-a41df1933103}\"/>" >> "$target"
	  echo "    <RDF:li RDF:resource=\"urn:mozilla:item:myphoneexplorer@fjsoft.at\"/>" >> "$target"
	  echo "  </RDF:Seq>" >> "$target"
	  echo "  <RDF:Description RDF:about=\"urn:mozilla:item:{e2fda1a4-762b-4020-b5ad-a41df1933103}\"" >> "$target"
	  echo "                   NS1:installLocation=\"app-profile\"" >> "$target"
	  echo "                   NS1:version=\"6.2.2.1\"" >> "$target"
	  echo "                   NS1:optionsURL=\"chrome://messenger/content/preferences/preferences.xul\"" >> "$target"
	  echo "                   NS1:iconURL=\"chrome://calendar/skin/cal-icon32.png\"" >> "$target"
	  echo "                   NS1:name=\"Lightning\"" >> "$target"
	  echo "                   NS1:description=\"An integrated calendar for Thunderbird\"" >> "$target"
	  echo "                   NS1:creator=\"Mozilla Calendar Project\"" >> "$target"
	  echo "                   NS1:homepageURL=\"http://www.mozilla.org/projects/calendar/\">" >> "$target"
	  echo "    <NS1:type NC:parseType=\"Integer\">2</NS1:type>" >> "$target"
	  echo "    <NS1:targetApplication RDF:resource=\"rdf:#$GqnK52\"/>" >> "$target"
	  echo "  </RDF:Description>" >> "$target"
	  echo "  <RDF:Description RDF:about=\"urn:mozilla:item:myphoneexplorer@fjsoft.at\"" >> "$target"
	  echo "                   NS1:installLocation=\"app-profile\"" >> "$target"
	  echo "                   NS1:version=\"2.0.23\"" >> "$target"
	  echo "                   NS1:name=\"MyPhoneExplorer\"" >> "$target"
	  echo "                   NS1:description=\"MyPhoneExplorer Synchronisation\"" >> "$target"
	  echo "                   NS1:creator=\"F.J. Wechselberger, N. Pueschel\"" >> "$target"
	  echo "                   NS1:homepageURL=\"http://www.fjsoft.at/\">" >> "$target"
	  echo "    <NS1:type NC:parseType=\"Integer\">2</NS1:type>" >> "$target"
	  echo "    <NS1:targetApplication RDF:resource=\"rdf:#$GqnK52\"/>" >> "$target"
	  echo "  </RDF:Description>" >> "$target"
	  echo "</RDF:RDF>" >> "$target"

	else
	  echo "existiert schon"
	fi
	unset target

fi
if the file extensions.rdf file already exists make sure that the versionnummers inside match the installed add-on-versions

6. ready to use


This time I used the reg function of wine. I think this is more elegant and I added a check for OS so the add-on shut still work an a windows.
@FJ Maybe this changes could find the way in the standard version, to make the wine support easier.

Verfasst: Do 25. Okt 2018, 12:23
von Pastim
Thanks. I'll have a think about trying this. My MPE is currently working well with the 2nd copy of Thunderbird, so I may leave it until I need to change something else. I've copied the instructions locally so I can find them if/when I need them.

Verfasst: So 11. Nov 2018, 12:30
von matthias
Thank you very much, @TreeNode!

In my case I installed MPE using a wineprefix (.wine_MPE) therefore I had to modify your functions.
Also I noticed that, when reading out the "PathToExe" value from the registry, it was returned with leading spaces, which made it necessary to add the trim()-function
@FJ it would be great if this could make it into the standard version! Maybe with a way to configure the wineprefix if someone installed it to a different location as I did...

Here are my versions of these functions:
there are two occurrences of "/path/to/wineprefix/" that you need to change to your prefix.

Code: Alles auswählen

function RegRead(subkey,valuename)
{
	var out = '';
	var os = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime).OS;
	if (os=="Linux"||IO.getFile("/usr/bin","wine").exists()){
		// um die Konstanten zu genierieren
		Components.classes["@mozilla.org/net/osfileconstantsservice;1"].getService(Components.interfaces.nsIOSFileConstantsService).init();
		// erzeuge ein tmp file mit dem inhalt #!/bin/bash \n\$1 \> \$2 um die rückgabe der bash in eine Datei zu schreiben
		var copyFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
		copyFile.append("copy.sh");
		copyFile.createUnique(copyFile.nsIFile.NORMAL_FILE_TYPE, 0o700);
		WriteFile(copyFile.path,"#!/bin/bash \n\$1 \> \$2");
		var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
		process.init(copyFile);
		var tmpFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
		tmpFile.append("Query.tmp");
		tmpFile.createUnique(tmpFile.NORMAL_FILE_TYPE, 0o600);

		//modification: use the env function to pass the wineprefix to wine
		var args = ["/usr/bin/env WINEPREFIX=/path/to/wineprefix/ wine reg Query HKCU\\"+subkey +" /v "+valuename, tmpFile.path];
		process.run(true, args, args.length);
		try {

			var out = ReadFile(tmpFile.path);
			out=out[2];
			out=out.split("REG_SZ ");
			out=out[1];
			//modification: trim the output to get rid of extra spaces
			out = out.trim();
			
			tmpFile.remove(false);
			copyFile.remove(false);
			//prüft ob es ein Systempfad ist(zweite Stelle ":")
			if(out.indexOf(":")==1){
				out= 'dosdevices/'+out.substr(0,1).toLowerCase()+out.substr(1,out.length-1);
				out = out.split('\\').join('/');//ersetzt alle \\ durch /
				out=OS.Constants.Path.homeDir+'/.wine_MPE/'+out;
			}
		}
		catch(ex) {
			Components.utils.reportError('Error reading HKCU\\' + subkey + ' : ' + valuename + ' : ' + ex);
		}
	}
	else{
		try {
			var wrk = Components.classes["@mozilla.org/windows-registry-key;1"].createInstance(Components.interfaces.nsIWindowsRegKey);
			wrk.open(wrk.ROOT_KEY_CURRENT_USER,subkey,wrk.ACCESS_READ);
			out = wrk.readStringValue(valuename);
			wrk.close();
		}
		catch(ex) {
			// Components.utils.reportError('Error reading HKCU\\' + subkey + ' : ' + valuename + ' : ' + ex);
		}
	}
	//Components.utils.reportError(out);
	return(out);
} 



Run: function(args)
{
	//var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
	var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
	
	args=[args];
	var os = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime).OS
	var path = RegRead("Software\\MyPhoneExplorer", "PathToExe");
	if (os=="Linux"||IO.getFile("/usr/bin","wine").exists()) {
		//modification: again use the env function to pass the wineprefix to wine
		args=["WINEPREFIX=/path/to/wineprefix/ /usr/bin/wine", path, args[0]];
		path= "/usr/bin/env";
	}
	if (path.length != 0) {
		try {
			//file.initWithPath(path);
			var file = new FileUtils.File(path);
			process.init(file);
			process.run(false, args, args.length);
			return;
		}
		catch(ex) {
			Components.utils.reportError('Could not run ' + path);
			return;
		}
	}
	Components.utils.reportError("Could not find MyPhoneExplorer.exe");
}, 

Verfasst: Mi 14. Nov 2018, 14:38
von TreeNode
Hallo matthias,
I think I‘ve got a solution for this problem.
Therefore I read the preferences of thunderbird.
If you’re using a WINEPREFIX go to thunderbird and open the Config Editor(To access the config editor, go to Edit > Preferences, select the Advanced panel, select the General tab, and click Config Editor.)
With a right-click, add a new String. The Name is ”myphoneexplorer.path_to_wine” and the value is the path to your wine-installation.
I think this should work.

Here the new version of the adjusted functions:

Code: Alles auswählen

function RegRead(subkey,valuename)
{
	var out = '';

	var os = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime).OS;

	if (os=="Linux"||IO.getFile("/usr/bin","wine").exists()){
		// um die Konstanten zu genierieren
		Components.classes["@mozilla.org/net/osfileconstantsservice;1"].getService(Components.interfaces.nsIOSFileConstantsService).init();
		//Ließt die Einstellung aus, falls wine an einem anderen Ort liegt, sollte man es dort in thunderbird eintragen
		var defaultWinePath =  OS.Constants.Path.homeDir+'/.wine';
		var	PathToWine = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch).getCharPref("myphoneexplorer.path_to_wine",defaultWinePath);

		// erzeuge ein tmp file mit dem inhalt #!/bin/bash \n\$1 \> \$2 um die rückgabe der bash in eine Datei zu schreiben
		var copyFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
		copyFile.append("copy.sh");
		copyFile.createUnique(copyFile.nsIFile.NORMAL_FILE_TYPE, 0o700);
		WriteFile(copyFile.path,"#!/bin/bash \n\$1 \> \$2");

		var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
		process.init(copyFile);
		var tmpFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
		tmpFile.append("Query.tmp");
		tmpFile.createUnique(tmpFile.NORMAL_FILE_TYPE, 0o600);
		//wegen Performanceeinbußen
		if(PathToWine==defaultWinePath){
			var args = ["wine reg Query HKCU\\"+subkey +" /v "+valuename, tmpFile.path];
		}else {
			var args = ["/usr/bin/env WINEPREFIX="+PathToWine+" wine reg Query HKCU\\"+subkey +" /v "+valuename, tmpFile.path];
		}
		process.run(true, args, args.length);
		try {
			out = ReadFile(tmpFile.path);
			out=out[2];
			out=out.split("REG_SZ    ");
			out=out[1];
			out=out.trim();
			//prüft ob es ein Systempfad ist(zweite Stelle ":")
			if(out.indexOf(":")==1){
				out=out.split('\ ').join('%'); //um mit Leerzeichen umzugehen
				if(PathToWine==defaultWinePath){
					args = ["winepath "+out, tmpFile.path];
				}else {
					args = ["/usr/bin/env WINEPREFIX="+PathToWine+" winepath "+out, tmpFile.path];
				}
				process.run(true, args, args.length);
				out=ReadFile(tmpFile.path);
				out=out[0].split('%').join(' ');
			}
			tmpFile.remove(false);
			copyFile.remove(false);
		}
		catch(ex) {
		 	Components.utils.reportError('Error reading HKCU\\' + subkey + ' : ' + valuename + ' : ' + ex);
		}
	}
	else{
		try {
			var wrk = Components.classes["@mozilla.org/windows-registry-key;1"].createInstance(Components.interfaces.nsIWindowsRegKey);
			wrk.open(wrk.ROOT_KEY_CURRENT_USER,subkey,wrk.ACCESS_READ);
			out = wrk.readStringValue(valuename);
			wrk.close();
		}
		catch(ex) {
		// 	Components.utils.reportError('Error reading HKCU\\' + subkey + ' : ' + valuename + ' : ' + ex);
		}
	}
	//Components.utils.reportError(out);
	return(out);
}

Run: function(args)
{
	//var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
	var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);


	args=[args];
	var os = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime).OS
	var path = RegRead("Software\\MyPhoneExplorer", "PathToExe");
	if (os=="Linux"||IO.getFile("/usr/bin","wine").exists()){

		var defaultWinePath =  OS.Constants.Path.homeDir+'/.wine';
		var	PathToWine = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch).getCharPref("myphoneexplorer.path_to_wine",defaultWinePath);
		//wegen Performanceeinbußen
		if(PathToWine==defaultWinePath){
			args=[path,args[0]];
			path= "/usr/bin/wine";
		}else {
			args=["WINEPREFIX="+PathToWINE+" /usr/bin/wine",path,args[0]];
			path= "/usr/bin/env";
		}

	}
	if (path.length != 0) {
		try
		{
			//file.initWithPath(path);
			var file = new FileUtils.File(path);
			process.init(file);
			process.run(false, args, args.length);
			return;
		}
		catch(ex)
		{
			Components.utils.reportError('Could not run ' + path);
			return;
		}
	}
	Components.utils.reportError("Could not find MyPhoneExplorer.exe");
},

Verfasst: Do 9. Mai 2019, 21:26
von Pastim
I recently had problems using the method of installing a windows version of thunderbird (I could not see my Home calendar). So I thought I should try the version linking direct to the linux thunderbird.

I cannot get Thunderbird to show in the MPE sync set-up. Is there any way to diagnose what I have done wrong? I have run the latest modified script.

I have to admit I'm still confused as to why I have to set up some entries in .wine when I am using a different wine prefix, so I may have done something wrong.

You might wonder why I use a separate prefix. I have had so many problems with wine applications that I find it much simpler to have a prefix for each application. That way I can wipe out one application without removing others as well.

Verfasst: Fr 10. Mai 2019, 15:23
von Pastim
Pastim hat geschrieben:I recently had problems using the method of installing a windows version of thunderbird (I could not see my Home calendar). So I thought I should try the version linking direct to the linux thunderbird.

I cannot get Thunderbird to show in the MPE sync set-up. Is there any way to diagnose what I have done wrong? I have run the latest modified script.

I have to admit I'm still confused as to why I have to set up some entries in .wine when I am using a different wine prefix, so I may have done something wrong.

You might wonder why I use a separate prefix. I have had so many problems with wine applications that I find it much simpler to have a prefix for each application. That way I can wipe out one application without removing others as well.
I have now sorted this out, but I got quite confused for many, many, hours.

Several things caused me to set things up incorrectly. First, the installation script is for running under .wine. Working out which bits needed changing to use my prefix, and which did not, took me a while. By trial and error I eventually discovered that the only thing that must be under .wine is the link to the Thunderbird profile (under Application Data/Thunderbird). All other changes can be under my own prefix. Why that one item must be under .wine I have no idea. Does anyone know?

I also think I used the wrong path in the thunderbird configuration editor. I started with it as ~/winmpe, but eventually used the full /home... syntax.

And then I didn't make the changes to mpe.js quite correctly. Stupid of me.

Anyway, it all works now, and only the one link has to be recreated if and when my .wine gets reset.

Thanks to all.

Verfasst: So 9. Jun 2019, 10:50
von Pastim
It's now failed again, getting 'Loading entries from Thunderbird failed'. Is this affecting anyone else? Thunderbird is on version 60.7, MPE add-on 2.0.24.

I was hoping it's a new mpe.js which just needs re-editting, but I've done that and it still fails.

Edit: I had almost given up, but rebooted the PC, and then it worked. Something must have kept running using the old mpe.js somehow. Anyway, all is now well, and I have turned off auto-update on the MPE extension. :D

Verfasst: Fr 1. Nov 2019, 09:24
von Pastim
This method has stopped working after an upgrade. I have updated ubuntu to 19.10 (from 19.04). I have tried clearing out mpe from wine and starting again, to no avail. I have checked that my mpe.js extension is still correct.
The problem now is that although mpe does start (or set the focus on) thunderbird correctly (so the thunderbird.bat file is working correctly) but mpe can't see the thunderbird profile. If I look at the mpe settings, and select thunderbird to sync, it waits and then reports 'Folder structure from Thunderbird could not be listed'.

The mpe log is as below. There is an activex error, but I'm not sure that's the issue. When I tried doing a sync before looking at the settings, I got "ErrMsg: Loading entries from Thunderbird failed!" before the ActiveX error message.

Can anyone helo?

Code: Alles auswählen

Logdatei MyPhoneExplorer
************************
Programmversion: 1.8.12
Datum:   01/11/2019

08:16:10.35       Windows Version=6.1
08:16:10.35       Setting Port: 999
08:16:10.35       Setting Baud: 115200
08:16:10.35       Avaiable Ports: COM0=; 
08:16:10.38       Main Load frmSplash
08:16:10.43       Load frmSplash...
08:16:10.44       Show splash...
08:16:10.44       frmSplash geladen
08:16:11.62       Hauptfenster wird geladen
08:16:11.81       Sidebar fertig geladen
08:16:11.98       UC SMS wird geladen
08:16:12.07       UC Phonebook wird geladen
08:16:12.13       UC Phonebook fertig geladen
08:16:12.13       UC Calls wird geladen
08:16:12.21       UC Organizer wird geladen
08:16:12.34       Organizer initiated
08:16:12.35       Startpage=1
08:16:12.36       UC Filebrowser wird geladen
08:16:12.51       UC Filebrowser fertig geladen
08:16:12.51       UC AppBrowser wird geladen
08:16:12.53       UC Notes wird geladen
08:16:12.56       UC Calls wird geladen
08:16:12.67       Setting Lastuser: motorola XT1039 [359290052199365]
08:16:12.69       PasswordCheck OK, check Userfolder, G_AppData=C:\users\crusty\Application Data\MyPhoneExplorer
08:16:12.69       CheckUserDirectory for: motorola XT1039 [359290052199365]
08:16:12.69       Userfolder=C:\users\crusty\Application Data\MyPhoneExplorer\motorola XT1039 [359290052199365]
08:16:12.69       ParseModell
08:16:12.70       Lade Userdatenbank: motorola XT1039 [359290052199365]
08:16:12.86       LoadGridLayout Error: 9
08:16:12.88       LoadDatafile: pb_metadata.xml(4347 Bytes)
08:16:12.91       LoadDatafile: Phonebook.dat(65131 Bytes)
08:16:13.24       Kontakte geladen
08:16:13.25       LoadDatafile: Calls.dat(1479 Bytes)
08:16:13.25       ParseDialedCalls needed 3ms
08:16:13.41       Anrufe geladen
08:16:13.41       Organizer LoadUser DefaultTimeColWidth=141
08:16:13.47       LoadDatafile: Organizer.dat(7854 Bytes)
08:16:13.48       LoadDatafile: cal_metadata.xml(725 Bytes)
08:16:13.51       Organizer geladen
08:16:13.52       LoadDatafile: Notes.dat(301 Bytes)
08:16:13.52       LoadDatafile: notes_metadata.xml(114 Bytes)
08:16:13.53       Notizen geladen
08:16:13.53       Load SMS Data...
08:16:13.53       LoadDatafile: SMS.dat(3515 Bytes)
08:16:13.53       SMS - Datenbank wird geladen...
08:16:13.53       SMS Laden  - Readfile: 2 Split: 0 Parse: 3 HandleMultiSMS: 1 Nachrichten: 16
08:16:13.56       RefreshList (Archive): Addrows=0 Sort=0 MenuUpdate=0 Redraw=0
08:16:13.58       SMS Data Loaded...
08:16:13.58       SMS geladen
08:16:13.83       Version check...
08:16:13.85       Hauptfenster fertig geladen
08:16:16.22       Refresh ComDescriptions...
08:16:16.38       Error in StartFritzboxSearch: 429 ActiveX component can't create object
08:16:21.47       fSyncContactSettings_Activate
08:16:31.67       ErrMsg: Folder structure from Thunderbird could not be listed!
08:16:42.33       Refresh ComDescriptions...
08:16:42.46       Error in StartFritzboxSearch: 429 ActiveX component can't create object
08:16:43.70       Device driver info:

Verfasst: Mo 4. Nov 2019, 18:28
von Pastim
Pastim hat geschrieben:This method has stopped working after an upgrade. I have updated ubuntu to 19.10 (from 19.04). I have tried clearing out mpe from wine and starting again, to no avail. I have checked that my mpe.js extension is still correct.
The problem now is that although mpe does start (or set the focus on) thunderbird correctly (so the thunderbird.bat file is working correctly) but mpe can't see the thunderbird profile. If I look at the mpe settings, and select thunderbird to sync, it waits and then reports 'Folder structure from Thunderbird could not be listed'.
....
I tried many things to get this to work. I re-did the mpe.js changes on a new version (2.0.25) of the mpe extension, but t-bird 68 was very reluctant to allow the extension to be installed at all. It did allow it eventually. But mpe still couldn't access the contacts or calendar. I eventually fell back on the old method of installing t-bird under wine and linking a few files to the linux t-bird. But even that initially had the same problem. After trying all sorts of things it suddenly worked! Then a bit later it didn't. I discovered that if the linux t-bird is running, mpe and the t-bird under wine cannot access the contacts or calendar. By stopping the linux t-bird it almost worked OK. I had to make one other change, which was to create a link from the wine t-bird profile folder to the whole calendar-data folder, rather than to the local.sqlite file within that folder.

So I now have:
- ubuntu 19.10
- linux t-bird 68.1.2

A wine 64 bit prefix containing:
- mpe 1.8.12
- 64 bit t-bird 68.2.1
- mpe extension 2.0.25 (I installed t-bird 60 first, so as to install the extension, then upgraded to 68 )

Links from the wine t-bird profile to the linux profile:
abook.mab linked to the abookn.mab that contains the contacts I want on my mobile
calendar-data folder
storage.sdb

Verfasst: Di 5. Nov 2019, 12:25
von TreeNode
Hallo finally I managed to write a little python-script to automate the process.
It should create the Registry-Entry if not existing.
It should create the Folder and the .bak file.
Most imported it should modify the installed Add-on.
After running the script, you should restart Thunderbird twice.

If you have an individual WinePrefix you have to modify the variable in line 12.
Note that python is a space sensitive language.


I tested my script on TB 68. Once the Addon is installed in TB 68 it works (only the version 2.0.25 is compatible. I took the .xpi form an other installation). Sometimes I get the Error in MPE: “Loading entries from Thunderbird failed!” if TB is not open(TB-Error: “calendar-startup-done observer registered”). Maybe it’s because I am testing in an fresh VM.

Code: Alles auswählen

#! /usr/bin/python3
import os
import subprocess
import zipfile
import tempfile
import configparser
import json
HOME=os.environ['HOME']


##Change WinePrefix if needed
WinePrefix=os.path.join(HOME,'.wine')




ThunderbirdPATH=os.path.join(HOME,'.thunderbird')
ThunderbirdExec_REG_KEY='HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\thunderbird.exe'
ThunderbirdExec_REG_DATA='C:\\Program Files\\Mozilla Thunderbird\\thunderbird.bat'
ThunderbirdExecPATH=os.path.join(WinePrefix,'drive_c','Program Files','Mozilla Thunderbird')
ThunderbirdData_REG_KEY='HKEY_USERS\\.Default\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders'
ThunderbirdData_RED_DATA='AppData'
###############
#changes in mpe.js

RegRead="""RegRead(subkey,valuename)
{
    var out = '';
    """+'var WINEPREFIX = "export WINEPREFIX='+WinePrefix+'";\n'+"""
    var os = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime).OS;

    if (os=="Linux"||IO.getFile("/usr/bin","wine").exists()){
        // erzeuge ein tmp file mit dem inhalt #!/bin/bash \\n\$1 \> \$2 um das Feedback der bash in eine Datei zu schreiben
        var copyFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
        copyFile.append("copy.sh");
        copyFile.createUnique(copyFile.nsIFile.NORMAL_FILE_TYPE, 0o700);
        WriteFile(copyFile.path,"#!/bin/bash \\n"+WINEPREFIX+"\\n\$@ \> \$0");

        var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
        process.init(copyFile);
        var args = ["wine","reg","Query","HKCU\\\\"+subkey +" /v "+valuename]
        process.run(true, args, args.length);
        try {
            out = ReadFile(copyFile.path);
            out=out[2];
            out=out.split("REG_SZ");
            out=out[1];
            out=out.trim();
            //prÃ\u0152ft ob es ein Systempfad ist(zweite Stelle ":")
            if(out.indexOf(":")==1){
                WriteFile(copyFile.path,"#!/bin/bash \\n"+WINEPREFIX+"\\n \$1 \\"\$2\\" \> \$0");
                args =["winepath",out]
                process.run(true, args, args.length);
                out=ReadFile(copyFile.path);
            }
            copyFile.remove(false);
        }
        catch(ex) {
             Components.utils.reportError('Error reading HKCU\\\\' + subkey + ' : ' + valuename + ' : ' + ex);
        }
    }
    else{
        try {
            var wrk = Components.classes["@mozilla.org/windows-registry-key;1"].createInstance(Components.interfaces.nsIWindowsRegKey);
            wrk.open(wrk.ROOT_KEY_CURRENT_USER,subkey,wrk.ACCESS_READ);
            out = wrk.readStringValue(valuename);
            wrk.close();
        }
        catch(ex) {
             Components.utils.reportError('Error reading HKCU\\\\' + subkey + ' : ' + valuename + ' : ' + ex);
        }
    }
    return(out);
}

// UUID-Generator inspired by http://www.scriptsearch.com/cgi-bin/jump.cgi?ID=3530

"""


Run=""" function(args)
{
    """+'var WINEPREFIX = "WINEPREFIX='+WinePrefix+'";\n'+"""
    //var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
    var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);


    args=[args];
    var os = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime).OS
    var path = RegRead("Software\\\\MyPhoneExplorer", "PathToExe");
    if (os=="Linux"||IO.getFile("/usr/bin","wine").exists()){
        args=[WINEPREFIX,"/usr/bin/wine",path,args[0]];
        path="/bin/bash";

    }
    if (path.length != 0) {
        try
        {
            //file.initWithPath(path);
            var file = new FileUtils.File(path);
            process.init(file);
            process.run(false, args, args.length);
            return;
        }
        catch(ex)
        {
            Components.utils.reportError('Could not run ' + path);
            return;
        }
    }
    Components.utils.reportError("Could not find MyPhoneExplorer.exe");
},

"""
#################################################




def linkAndCreateWineToLinuxThunderbird():
    env=os.environ.copy()
    env["WINEPREFIX"]=WinePrefix
    
    cmd=['wine','reg','query',ThunderbirdExec_REG_KEY]
    process =subprocess.Popen(cmd,env=env,stdout=subprocess.PIPE)
    process.communicate()
    returncode = process.returncode
    if returncode == 0:
        return
    cmd=['wine','reg','add',ThunderbirdExec_REG_KEY,'/v','','/t','REG_SZ','/d',ThunderbirdExec_REG_DATA]
    subprocess.Popen(cmd,env=env,stdout=subprocess.PIPE).communicate()
    os.makedirs(ThunderbirdExecPATH,exist_ok=True)
    with open(os.path.join(ThunderbirdExecPATH,'thunderbird.bat'),'w') as file:
        file.write('start /unix /usr/bin/thunderbird %1 %2')
    os.chmod(os.path.join(ThunderbirdExecPATH,'thunderbird.bat'), 777)
    cmd=['wine','reg','query',ThunderbirdData_REG_KEY,'/v',ThunderbirdData_RED_DATA]
    out,err=subprocess.Popen(cmd,env=env,stdout=subprocess.PIPE).communicate()
    result=out.decode().rstrip().split("REG_SZ")[1]
    thunderbirdwpath=result.lstrip().rstrip()
    
    cmd=['winepath',thunderbirdwpath]
    out,err=subprocess.Popen(cmd,env=env,stdout=subprocess.PIPE).communicate()
    ThunderbirdDataPATH=os.path.join(out.decode().rstrip().lstrip(),'Thunderbird')
    #Softlink
    if os.path.exists(ThunderbirdDataPATH):
        return
    cmd=['ln','-s',ThunderbirdPATH,ThunderbirdDataPATH]
    subprocess.Popen(cmd,stdout=subprocess.PIPE).communicate()

    
def modifyMPEAddOnForThunderbird(path):
    xpiPath=os.path.join(path,'extensions','myphoneexplorer@fjsoft.at.xpi')
    addonFile='components/mpe.js'
    tmpfd, tmpname = tempfile.mkstemp(dir=os.path.dirname(xpiPath))
    os.close(tmpfd)
    with zipfile.ZipFile(xpiPath) as mpe_xpi:
        with mpe_xpi.open(addonFile) as mpe_js:
            cache=mpe_js.read()
    
    #modify mpe.js
    sourcecode=cache.decode('iso-8859-1')
    runsplit=sourcecode.split('Run:')
    ssplit=runsplit[1].split('SendMessage:')
    runsplit[1]='SendMessage:'.join([Run,ssplit[1]])
    sourcecode="Run: ".join(runsplit)
    
    fsplit=sourcecode.split('function ')
    fsplit[4]=RegRead    
    sourcecode='function '.join(fsplit)
    
    
    #save in xpi
    with zipfile.ZipFile(xpiPath,'r') as zipin:
        with zipfile.ZipFile(tmpname,'w') as zipout:
            zipout.comment=zipout.comment
            for elem in zipin.infolist():
                if elem.filename != addonFile:
                    zipout.writestr(elem,zipin.read(elem.filename))

    os.remove(xpiPath)
    os.rename(tmpname,xpiPath)
    with zipfile.ZipFile(xpiPath,mode='a',compression=zipfile.ZIP_DEFLATED) as mpe_xpi:
        with mpe_xpi.open(addonFile,mode='w') as mpe_js:
            mpe_js.write(sourcecode.encode()) 

def createRDF(path):
    head="""<?xml version="1.0"?>
<RDF:RDF xmlns:NS1="http://www.mozilla.org/2004/em-rdf#"
         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    """
    body=''
    tail="""
</RDF:RDF>
    """
    with open(os.path.join(path,'extensions.json')) as file:
        data = json.load(file)
    addons=data['addons']

    for addon in addons :
        body+='  <RDF:Description RDF:about="urn:mozilla:item:'
        body+=addon['id']
        body+='"\n'
        body+='                   NS1:version="'
        body+=addon['version']
        body+='">\n'
        body+='  </RDF:Description>\n'
    
    with open(os.path.join(path,'extensions.rdf'),mode='w') as file:
        file.write(''.join([head,body,tail]))

def getThunderbirdProfileFolder():
    ini = configparser.ConfigParser()
    ini.read(os.path.join(ThunderbirdPATH,'profiles.ini'))
    if ini.has_option('General', 'Version'):
        for user in ini.sections():
            if ini.has_option(user, 'Default'):
                try:
                    ini.getboolean(user, 'Default') 
                except:
                    folder=os.path.join(ThunderbirdPATH,ini.get(user,'Default'))
                    break
        return folder
        
    else:
        for user in ini.sections():
            if ini.has_option(user, 'Default'):
                if ini.getboolean(user, 'Default'): 
                    break
        if ini.getboolean(user, 'IsRelative'):
            folder=os.path.join(ThunderbirdPATH,ini.get(user,'Path'))
        else:
            folder=ini.get(user,'Path')
        return folder


linkAndCreateWineToLinuxThunderbird()
profilePath=getThunderbirdProfileFolder()
print(profilePath)
modifyMPEAddOnForThunderbird(profilePath)
createRDF(profilePath)

print("need to restart your Thunderbird with deactivated Add-ons and than start it normal again (to force the reload of the Add-ons)")


Verfasst: Di 27. Okt 2020, 16:49
von Pastim
TreeNode hat geschrieben:Hallo finally I managed to write a little python-script to automate the process.
It should create the Registry-Entry if not existing.
It should create the Folder and the .bak file.
Most imported it should modify the installed Add-on.
After running the script, you should restart Thunderbird twice.
...............
Have you tried this with Thunderbird 78 and the new xpi? I haven't dared yet.

Verfasst: Mi 28. Okt 2020, 18:21
von Pastim
Having upgraded to Ubuntu 20.10 and Thunderbird 78, I have been unable to get a solution working under wine.

I can't get the myphoneexplorer xpi to install under Thunderbird running under wine.

The solution for linking mpe to Thunderbird under linux doesn't work any more since the xpi has been much changed for version 78.

I have, with great regret, had to find some other solution, for now at least.

If anyone can find a solution with mpe I'd be more than happy to give it a try.

Verfasst: Fr 20. Nov 2020, 14:33
von Pastim
After many attempts I managed to get Thunderbird 78 running under wine, with the latest mpe xpi file. mpe is also installed, but now it says it can't read the thunderbird folders

Has anyone else got this to work?

Verfasst: So 24. Jan 2021, 20:51
von matthias
Hello Pastim,
I tried quite a few things a while ago.
Unfortunately, I'm not familiar with thunderbird extensions, so I wasn't able to find a solution...
It seems we have to wait for TreeNode or someone like him to solve it... :(

Verfasst: Mo 1. Feb 2021, 21:03
von Pastim
I had another go today, now with wine 6.1 on ubuntu 20.10, Thunderbird 78.6.1 installed under wine. No luck.

mpe 1.8.15 reports that it can see the thunderbird release directory, but cannot see the address book or calendar file. Wine give a flood of messages like:

Code: Alles auswählen

0200:fixme:file:server_get_file_info Unsupported info class 5
I also ran thunderbird.exe from the command line with option -mpe list-cal c:\cal.txt, and got the same errors without running mpe.

It therefore looks as if the mpe add-on, myphoneexplorer-3.0.12-tb,xpi, cannot do something under wine. I have no idea what else to try and add to wine to fix this.

I wonder whether any of the German-speaking users have seen and solved this problem.

Verfasst: Fr 5. Feb 2021, 00:15
von matthias
I haven't seen any solution in the german part either...

When I start the native thunderbird version under linux I can see following error in the error log of thunderbird:

Code: Alles auswählen

ExtensionError: No such native application myphoneexplorer.extension
Do you experience that as well?

Verfasst: Fr 5. Feb 2021, 10:06
von Pastim
matthias hat geschrieben:I haven't seen any solution in the german part either...

When I start the native thunderbird version under linux I can see following error in the error log of thunderbird:

Code: Alles auswählen

ExtensionError: No such native application myphoneexplorer.extension
Do you experience that as well?
Thanks.

I'm installing thunderbird under wine, and linking the address book to my thunderbird under linux. I managed to install the mpe extension (version myphoneexplorer-3.0.12-tb) under wine by first installing IE8 in the wine section for Thunderbird 78 (using winetricks).

I have previously tried installing the extension in the linux version of thunderbird, but it does not work, not least because the modifications made by treenode do not seem to apply to the revised extension for thunderbird 78.