Changeset dd1f45
- Timestamp:
- Oct 5, 2010, 1:54:59 PM (10 years ago)
- Branches:
- ng_0.6, ng_0.8, ng_0.9
- Children:
- 0852d9
- Parents:
- 045bfd
- Location:
- chrome/content/v_identity
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
chrome/content/v_identity/vI_context.xul
r045bfd rdd1f45 65 65 <menuitem label="&vident.vI_Menu.DataEditor.label;" 66 66 oncommand="window.open('chrome://v_identity/content/vI_rdfDataTree.xul', '', 'chrome, dialog, resizable=yes');" /> 67 <menuitem label="&importCmd.label;" accesskey="&importCmd.accesskey;" oncommand="v I_rdfDatasource = new vI_rdfDatasource(); vI_rdfDatasource.import('virtualIdentity.rdf')"/>68 <menuitem label="&exportCmd.label;" accesskey="&exportCmd.accesskey;" oncommand="v I_rdfDatasource = new vI_rdfDatasource(); vI_rdfDatasource.export('virtualIdentity.rdf')"/>67 <menuitem label="&importCmd.label;" accesskey="&importCmd.accesskey;" oncommand="var vI_localRdfDatasource = new vI_rdfDatasourceImporter('virtualIdentity.rdf');"/> 68 <menuitem label="&exportCmd.label;" accesskey="&exportCmd.accesskey;" oncommand="var vI_localRdfDatasource = new vI_rdfDatasource(); vI_localRdfDatasource.export('virtualIdentity.rdf')"/> 69 69 </menupopup> 70 70 </menu> -
chrome/content/v_identity/vI_prefDialog.xul
r045bfd rdd1f45 574 574 <spacer class="paragraph"/> 575 575 <button id="VIdent_identity.storage.openEditor" label="&vI_prefDialog.storage.openEditor;" oncommand="openDialog('chrome://v_identity/content/vI_rdfDataTree.xul', '', 'chrome, dialog, resizable=yes');" /> 576 <button id="VIdent_identity.storage.import" label="&vI_prefDialog.storage.import;" oncommand="v I_rdfDatasource = new vI_rdfDatasource(); vI_rdfDatasource.import('virtualIdentity.rdf')" />577 <button id="VIdent_identity.storage.export" label="&vI_prefDialog.storage.export;" oncommand="v I_rdfDatasource = new vI_rdfDatasource(); vI_rdfDatasource.export('virtualIdentity.rdf')" />576 <button id="VIdent_identity.storage.import" label="&vI_prefDialog.storage.import;" oncommand="var vI_localRdfDatasource = new vI_rdfDatasourceImporter('virtualIdentity.rdf');" /> 577 <button id="VIdent_identity.storage.export" label="&vI_prefDialog.storage.export;" oncommand="var vI_localRdfDatasource = new vI_rdfDatasource(); vI_localRdfDatasource.export('virtualIdentity.rdf')" /> 578 578 </groupbox> 579 579 </tabpanel> -
chrome/content/v_identity/vI_rdfAccountMismatchDialog.js
r045bfd rdd1f45 52 52 vI_rdfAccountMismatchDialog.mismatchItems[i].key = document.getElementById("mismatchLine_" + i).key 53 53 } 54 /* window.argument[2] stores callback function*/55 window.arguments[2] (vI_rdfAccountMismatchDialog.type, vI_rdfAccountMismatchDialog.mismatchItems);54 /* window.argument[2] stores callback parent */ 55 window.arguments[2].repairAccountMismatch(vI_rdfAccountMismatchDialog.type, vI_rdfAccountMismatchDialog.mismatchItems); 56 56 } 57 57 } -
chrome/content/v_identity/vI_rdfDataTree.xul
r045bfd rdd1f45 115 115 <menu id="tasksMenu" label="&tasksMenu.label;" accesskey="&tasksMenu.accesskey;"> 116 116 <menupopup> 117 <menuitem label="&importCmd.label;" accesskey="&importCmd.accesskey;" oncommand="v I_rdfDatasource = new vI_rdfDatasource(); vI_rdfDatasource.import('virtualIdentity.rdf')"/>118 <menuitem label="&exportCmd.label;" accesskey="&exportCmd.accesskey;" oncommand="v I_rdfDatasource = new vI_rdfDatasource(); vI_rdfDatasource.export('virtualIdentity.rdf')"/>117 <menuitem label="&importCmd.label;" accesskey="&importCmd.accesskey;" oncommand="var vI_localRdfDatasource = new vI_rdfDatasourceImporter('virtualIdentity.rdf');"/> 118 <menuitem label="&exportCmd.label;" accesskey="&exportCmd.accesskey;" oncommand="var vI_localRdfDatasource = new vI_rdfDatasource(); vI_localRdfDatasource.export('virtualIdentity.rdf')"/> 119 119 </menupopup> 120 120 </menu> -
chrome/content/v_identity/vI_rdfDatasource.js
r045bfd rdd1f45 25 25 26 26 27 function vI_rdfDatasource(rdfFileName, dontRegisterObserver , rdfNS) {27 function vI_rdfDatasource(rdfFileName, dontRegisterObserver) { 28 28 this._rdfFileName = rdfFileName; 29 this._rdfNS = rdfNS?rdfNS:"http://virtual-id.absorb.it/";30 29 if (this._rdfFileName) this.init(); 31 30 if (!dontRegisterObserver) this.AccountManagerObserver.register(); … … 38 37 _rdfDataSource : null, 39 38 _rdfFileName : null, 40 _rdfNS : null, // defaults to "http://virtual-id.absorb.it/"39 _rdfNS : "http://virtual-id.absorb.it/", 41 40 _rdfNSStorage : "vIStorage", 42 41 _rdfNSEmail : "vIStorage/email", … … 81 80 82 81 init: function() { 83 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource init with namespace " + this._rdfNS + ".\n");82 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource init.\n"); 84 83 85 84 this._openRdfDataSource(); … … 91 90 this.storeRDFVersion(); 92 91 93 this.refreshAccountInfo();94 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource init done.\n");92 // this.refreshAccountInfo(); 93 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource init done.\n"); 95 94 }, 96 95 … … 110 109 var fileURI = protoHandler.newFileURI(newFile); 111 110 112 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource read rdf from '" + fileURI.spec + "'\n");111 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource init: read rdf from '" + fileURI.spec + "'\n"); 113 112 114 113 this._rdfDataSource = … … 119 118 120 119 _initContainers: function() { 121 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource _initContainers with namespace " + this._rdfNS + ".\n");122 120 try { // will possibly fail before upgrade 123 121 var storageRes = this._rdfService … … 383 381 384 382 searchIdentityMismatch : function() { 385 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchIdentityMismatch \n");383 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchIdentityMismatch"); 386 384 387 385 var relevantIDs = this.getRelevantIDs(); … … 391 389 .getService(Components.interfaces.nsIMsgAccountManager); 392 390 for (var id in relevantIDs) { 393 var identity = AccountManager.getIdentity(id) 391 var found = false; 392 for (var i = 0; i < AccountManager.accounts.Count(); i++) { 393 var account = AccountManager.accounts.GetElementAt(i) 394 .QueryInterface(Components.interfaces.nsIMsgAccount); 395 for (var j = 0; j < account.identities.Count(); j++) { 396 var identity = account.identities.GetElementAt(j).QueryInterface(Components.interfaces.nsIMsgIdentity); 397 if (id == identity.key) { found = true; break; } 398 } 399 if (found) break; 400 } 394 401 var resource = this._rdfService.GetResource(this._rdfNS + this._rdfNSIdentities + "/" + id); 395 402 var rdfIdentityName = this._getRDFValue(resource, "identityName"); 396 403 var rdfEmail = this._getRDFValue(resource, "email"); 397 404 var rdfFullName = this._getRDFValue(resource, "fullName") 398 if ( !identity || rdfIdentityName != identity.identityName && rdfEmail != identity.email) 399 mismatchIDs.push( { oldkey: id, label : rdfIdentityName, ext1: rdfEmail, ext2: rdfFullName, count: relevantIDs[id], key: "" } ) 405 406 if ( !found || rdfIdentityName != identity.identityName && rdfEmail != identity.email) 407 mismatchIDs.push( { oldkey: id, label : rdfIdentityName, ext1: rdfEmail, ext2: rdfFullName, count: relevantIDs[id], key: "" } ) 400 408 } 401 409 if (mismatchIDs.length > 0) { 402 if (vI_notificationBar) vI_notificationBar.dump(" ## vI_rdfDatasource: searchIdentityMismatchfound mismatches on id(s).\n");410 if (vI_notificationBar) vI_notificationBar.dump(" found mismatches on id(s).\n"); 403 411 404 412 window.openDialog("chrome://v_identity/content/vI_rdfAccountMismatchDialog.xul",0, 405 413 "chrome, dialog, modal, alwaysRaised, resizable=yes", "identity", mismatchIDs, 406 /* callback : */ this.repairAccountMismatch).focus();414 /* callback chance: */ this).focus(); 407 415 return true; 408 416 } 409 417 else { 410 if (vI_notificationBar) vI_notificationBar.dump(" ## vI_rdfDatasource: searchIdentityMismatchfound no mismatch\n");418 if (vI_notificationBar) vI_notificationBar.dump(" found no mismatch\n"); 411 419 return false; 412 420 } … … 414 422 415 423 repairAccountMismatch : function(type, mismatchItems) { 416 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: repairAccountMismatch\n");417 424 var keyField = (type == "identity")?"id":"smtp" // field to change is 'id' or 'smtp' dependent on type 418 425 for (var i = 0; i < mismatchItems.length; i++) { … … 453 460 454 461 searchSmtpMismatch : function() { 455 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchSmtpMismatch \n");462 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchSmtpMismatch"); 456 463 457 464 var relevantSMTPs = this.getRelevantSMTPs(); 458 465 var mismatchSMTPs = []; 459 466 460 var SmtpService = Components.classes["@mozilla.org/messengercompose/smtp;1"]461 .getService(Components.interfaces.nsISmtpService);462 467 for (var smtp in relevantSMTPs) { 463 var server = SmtpService.getServerByKey(smtp) 468 var servers = Components.classes["@mozilla.org/messengercompose/smtp;1"] 469 .getService(Components.interfaces.nsISmtpService).smtpServers; 470 var found = false; 471 if (typeof(servers.Count) == "undefined") // TB 3.x 472 while (servers && servers.hasMoreElements()) { 473 var server = servers.getNext(); 474 if (server instanceof Components.interfaces.nsISmtpServer && 475 !server.redirectorType && smtp == server.key) { 476 found = true; break; 477 } 478 } 479 else // TB 2.x 480 for (var i=0 ; i < servers.Count(); i++) { 481 var server = servers.QueryElementAt(i,Components.interfaces.nsISmtpServer); 482 if (!server.redirectorType && smtp == server.key) { 483 found = true; break; 484 } 485 } 464 486 var resource = this._rdfService.GetResource(this._rdfNS + this._rdfNSSMTPservers + "/" + smtp); 465 487 var rdfSMTPlabel = this._getRDFValue(resource, "label"); 466 488 var rdfHostname = this._getRDFValue(resource, "hostname"); 467 489 var rdfUsername = this._getRDFValue(resource, "username") 468 if (! server|| rdfSMTPlabel != (server.description?server.description:server.hostname) && rdfHostname != server.hostname)490 if (!found || rdfSMTPlabel != (server.description?server.description:server.hostname) && rdfHostname != server.hostname) 469 491 mismatchSMTPs.push( { oldkey: smtp, label : rdfSMTPlabel, ext1: rdfHostname, ext2: rdfUsername, count: relevantSMTPs[smtp], key: "" } ) 470 492 } 471 493 if (mismatchSMTPs.length > 0) { 472 if (vI_notificationBar) vI_notificationBar.dump(" ## vI_rdfDatasource: searchSmtpMismatchfound mismatches on smtp(s).\n");494 if (vI_notificationBar) vI_notificationBar.dump(" found mismatches on smtp(s).\n"); 473 495 window.openDialog("chrome://v_identity/content/vI_rdfAccountMismatchDialog.xul",0, 474 496 "chrome, dialog, modal, alwaysRaised, resizable=yes", "smtp", mismatchSMTPs, 475 /* callback: */ this .repairAccountMismatch).focus();497 /* callback: */ this).focus(); 476 498 return true; 477 499 } 478 500 else { 479 if (vI_notificationBar) vI_notificationBar.dump(" ## vI_rdfDatasource: searchSmtpMismatchfound no mismatch\n");501 if (vI_notificationBar) vI_notificationBar.dump(" found no mismatch\n"); 480 502 return false; 481 503 } … … 535 557 filePicker.appendFilter("RDF Files","*.rdf"); 536 558 537 if (filePicker.show() == Components.interfaces.nsIFilePicker.returnOK) {559 if (filePicker.show() != Components.interfaces.nsIFilePicker.returnCancel) { 538 560 var rdfDataFile = Components.classes["@mozilla.org/file/local;1"] 539 561 .createInstance(Components.interfaces.nsILocalFile); … … 704 726 705 727 updateRDF : function (recDescription, recType, localIdentityData, storeBaseID, storeSMTP, prevRecDescription, prevRecType) { 706 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource (" + this._rdfNS + "): updateRDF recDescription=" + recDescription + " localIdentityData.email=" + localIdentityData.email + ".\n");728 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource (" + this._rdfNS + "): updateRDF recDescription=" + recDescription + " localIdentityData.email=" + localIdentityData.email + ".\n"); 707 729 708 730 // if (!localIdentityData.email) { … … 717 739 var resource = this._getRDFResourceForVIdentity(prevRecDescription, prevRecType); 718 740 if (!resource) return; 719 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: updateRDF " + resource.ValueUTF8 + ".\n");741 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: updateRDF " + resource.ValueUTF8 + ".\n"); 720 742 721 743 var position = this.getContainer(recType).IndexOf(resource); // check for index in new recType … … 736 758 localIdentityData.extras.loopForRDF(this, resource, "set"); 737 759 738 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource (" + this._rdfFileName + "): updateRDF add " + resource.ValueUTF8 + " at position " + position + ".\n");760 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: updateRDF add " + resource.ValueUTF8 + " at position " + position + ".\n"); 739 761 if (position != -1) this.getContainer(recType).InsertElementAt(resource, position, true); 740 762 else this.getContainer(recType).AppendElement(resource); … … 742 764 743 765 _setRDFValue : function (resource, field, value) { 744 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: _setRDFValue " + resource.ValueUTF8 + " " + field + " " + value + ".\n");766 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: _setRDFValue " + resource.ValueUTF8 + " " + field + " " + value + ".\n"); 745 767 if (!value) return value; // return if some value was not set. 746 768 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource _setRDFValue " + this._rdfService + " " + this._rdfDataSource + "\n"); … … 784 806 } 785 807 786 808 // create with name of the file to import into 787 809 function vI_rdfDatasourceImporter(rdfFileName) { 788 810 this._rdfFileName = rdfFileName; … … 791 813 792 814 vI_rdfDatasourceImporter.prototype = { 815 _rdfService : Components.classes["@mozilla.org/rdf/rdf-service;1"] 816 .getService(Components.interfaces.nsIRDFService), 793 817 _rdfDataSource : null, 794 818 _rdfFileName : null, … … 825 849 }, 826 850 851 _translateRelevantIDs : function() { 852 var relevantIDs = this._rdfImportDataSource.getRelevantIDs(); 853 for (var id in relevantIDs) { 854 var resource = this._rdfService.GetResource(this._rdfImportDataSource._rdfNS + this._rdfImportDataSource._rdfNSIdentities + "/" + id); 855 var values = { id : null, identityName : null, email : null, fullName : null } 856 values.identityName = this._rdfImportDataSource._getRDFValue(resource, "identityName"); 857 values.email = this._rdfImportDataSource._getRDFValue(resource, "email"); 858 values.fullName = this._rdfImportDataSource._getRDFValue(resource, "fullName"); 859 values.id = this._getMatchingIdentity(values.identityName, values.email, values.fullName); 860 values.id = values.id?values.id:"import_" + id 861 relevantIDs[id] = values; 862 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: translate relevant ID from previous '" + id + "' to current '" + relevantIDs[id].id + "'\n"); 863 } 864 return relevantIDs; 865 }, 866 867 _storeMappedIDs : function(relevantIDs) { 868 for (var id in relevantIDs) { 869 if (relevantIDs[id].id == "import_" + id) { 870 var resource = this._rdfService 871 .GetResource(this._rdfDataSource._rdfNS + this._rdfDataSource._rdfNSIdentities + "/" + relevantIDs[id].id); 872 this._rdfDataSource._setRDFValue(resource, "identityName", relevantIDs[id].identityName); 873 this._rdfDataSource._setRDFValue(resource, "fullName", relevantIDs[id].fullName); 874 this._rdfDataSource._setRDFValue(resource, "email", relevantIDs[id].email); 875 876 var position = this._rdfDataSource._identityContainer.IndexOf(resource); // check for index in new recType 877 if (position != -1) this._rdfDataSource._identityContainer.InsertElementAt(resource, position, false); 878 else this._rdfDataSource._identityContainer.AppendElement(resource); 879 } 880 } 881 }, 882 883 _translateRelevantSMTPs : function() { 884 var relevantSMTPs = this._rdfImportDataSource.getRelevantSMTPs(); 885 for (var smtp in relevantSMTPs) { 886 var resource = this._rdfService.GetResource(this._rdfImportDataSource._rdfNS + this._rdfImportDataSource._rdfNSSMTPservers + "/" + smtp); 887 var values = { smtp : null, label : null, hostname : null, username : null } 888 values.label = this._rdfImportDataSource._getRDFValue(resource, "label"); 889 values.hostname = this._rdfImportDataSource._getRDFValue(resource, "hostname"); 890 values.username = this._rdfImportDataSource._getRDFValue(resource, "username"); 891 values.smtp = this._getMatchingSMTP(values.label, values.hostname, values.username); 892 values.smtp = values.smtp?values.smtp:"import_" + smtp; 893 relevantSMTPs[smtp] = values; 894 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: translate relevant SMTP from previous '" + smtp + "' to current '" + relevantSMTPs[smtp].smtp + "'\n"); 895 } 896 return relevantSMTPs; 897 }, 898 899 _storeMappedSMTPs : function(relevantSMTPs) { 900 for (var smtp in relevantSMTPs) { 901 if (relevantSMTPs[smtp].smtp == "import_" + smtp) { 902 var resource = this._rdfService 903 .GetResource(this._rdfDataSource._rdfNS + this._rdfDataSource._rdfNSSMTPservers + "/" + relevantSMTPs[smtp].smtp); 904 this._rdfDataSource._setRDFValue(resource, "label", relevantSMTPs[smtp].label); 905 this._rdfDataSource._setRDFValue(resource, "hostname", relevantSMTPs[smtp].hostname); 906 this._rdfDataSource._setRDFValue(resource, "username", relevantSMTPs[smtp].username); 907 908 var position = this._rdfDataSource._smtpContainer.IndexOf(resource); // check for index in new recType 909 if (position != -1) this._rdfDataSource._smtpContainer.InsertElementAt(resource, position, false); 910 else this._rdfDataSource._smtpContainer.AppendElement(resource); 911 } 912 } 913 }, 914 827 915 import : function() { 828 916 var filePicker = Components.classes["@mozilla.org/filepicker;1"] … … 834 922 835 923 if (filePicker.show() == Components.interfaces.nsIFilePicker.returnOK) { 836 if (vI_notificationBar) vI_notificationBar.dump(" ## vI_rdfDatasourceImporter import: preparation:\n");924 if (vI_notificationBar) vI_notificationBar.dump("\n## vI_rdfDatasourceImporter IMPORT\n## vI_rdfDatasourceImporter import: preparation:\n"); 837 925 838 926 var importRdfDataFile = Components.classes["@mozilla.org/file/local;1"] … … 842 930 var delimiter = (file.path.match(/\\/))?"\\":"/"; 843 931 importRdfDataFile.initWithPath(file.path + delimiter + this._rdfFileName + "_import"); 844 // importRdfDataFile.createUnique( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 600); 845 846 var inp_fstream = Components.classes["@mozilla.org/network/file-input-stream;1"] 847 .createInstance(Components.interfaces.nsIFileInputStream); 848 var inp_cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"] 849 .createInstance(Components.interfaces.nsIConverterInputStream); 850 var out_fstream = Components.classes["@mozilla.org/network/file-output-stream;1"] 851 .createInstance(Components.interfaces.nsIFileOutputStream); 852 var out_cstream = Components.classes["@mozilla.org/intl/converter-output-stream;1"] 853 .createInstance(Components.interfaces.nsIConverterOutputStream); 854 855 inp_fstream.init(filePicker.file, -1, 0, 0); 856 inp_cstream.init(inp_fstream, "UTF-8", 0, 0); // you can use another encoding here if you wish 857 out_fstream.init(importRdfDataFile, 0x04 | 0x08 | 0x20, 0600, 0); // readwrite, create, truncate 858 out_cstream.init(out_fstream, "UTF-8", 0, 0); 859 860 var regExpNamespace = new RegExp("http://virtual-id.absorb.it/","g"); 861 let (str = {}) { let read = 0; 862 do { 863 read = inp_cstream.readString(0xffffffff, str); // read as much as we can and put it in str.value 864 var string = str.value.replace(regExpNamespace, "http://virtual-id-import.absorb.it/"); 865 // out_fstream.write(string, string.length); 866 out_cstream.writeString(string); 867 } while (read != 0); 868 } 869 inp_cstream.close(); 870 out_cstream.close(); 932 filePicker.file.copyTo(importRdfDataFile.parent,importRdfDataFile.leafName); 871 933 872 934 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: copied file from " + filePicker.file.path + " to " + importRdfDataFile.path + "'\n"); 873 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: transferred NAMESPACES of import-file\n");874 935 875 936 // init Datasources 876 this._rdfImportDataSource = new vI_rdfDatasource(importRdfDataFile.leafName, true, "http://virtual-id-import.absorb.it/"); 877 878 // search matching Identities for any used ones 879 var relevantIDs = this._rdfImportDataSource.getRelevantIDs(); 880 for (var id in relevantIDs) { 881 var resource = this._rdfImportDataSource._rdfService.GetResource(this._rdfImportDataSource._rdfNS + this._rdfImportDataSource._rdfNSIdentities + "/" + id); 882 var rdfIdentityName = this._rdfImportDataSource._getRDFValue(resource, "identityName"); 883 var rdfEmail = this._rdfImportDataSource._getRDFValue(resource, "email"); 884 var rdfFullName = this._rdfImportDataSource._getRDFValue(resource, "fullName"); 885 var newId = this._getMatchingIdentity(rdfIdentityName, rdfEmail, rdfFullName); 886 relevantIDs[id] = newId?newId:"import_" + id; 887 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: translate relevant ID from " + id + " to " + relevantIDs[id] + "'\n"); 888 } 889 // search matching SMTPs for any used ones 890 var relevantSMTPs = this._rdfImportDataSource.getRelevantSMTPs(); 891 for (var smtp in relevantSMTPs) { 892 var resource = this._rdfImportDataSource._rdfService.GetResource(this._rdfImportDataSource._rdfNS + this._rdfImportDataSource._rdfNSSMTPservers + "/" + smtp); 893 var rdfSMTPlabel = this._rdfImportDataSource._getRDFValue(resource, "label"); 894 var rdfHostname = this._rdfImportDataSource._getRDFValue(resource, "hostname"); 895 var rdfUsername = this._rdfImportDataSource._getRDFValue(resource, "username") 896 var newSMTP = this._getMatchingSMTP(rdfSMTPlabel, rdfHostname, rdfUsername); 897 relevantSMTPs[smtp] = newSMTP?newSMTP:"import_" + smtp; 898 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: translate relevant SMTP from " + smtp + " to " + relevantSMTPs[smtp] + "'\n"); 899 } 937 this._rdfImportDataSource = new vI_rdfDatasource(importRdfDataFile.leafName, true); 938 939 // search matching IDs and SMTPs for anyones used in import-file 940 var relevantIDs = this._translateRelevantIDs(); 941 var relevantSMTPs = this._translateRelevantSMTPs(); 900 942 901 943 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: preparation done.\n"); 902 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: starting import: ");944 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: starting import:\n"); 903 945 904 946 for each (treeType in Array("email", "maillist", "newsgroup", "filter")) { 947 // re-initialize importDataSource to point rdfService to the right Resources 948 this._rdfImportDataSource = new vI_rdfDatasource(importRdfDataFile.leafName, true); 905 949 var container = this._rdfImportDataSource.getContainer(treeType) 906 if (vI_notificationBar) vI_notificationBar.dump("\n## vI_rdfDatasource importing " + treeType + " :" + container.GetCount()+ "datasets from " + this._rdfImportDataSource._rdfDataSource.URI + "\n"); 950 if (container.GetCount() == 0) continue; 951 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter importing " + treeType + ": " + container.GetCount()+ " datasets from " + this._rdfImportDataSource._rdfDataSource.URI + "\n"); 907 952 var enumerator = container.GetElements(); 908 this._rdfDataSource = new vI_rdfDatasource("virtualIdentity.rdf", true, "http://virtual-id.absorb.it/"); 953 // re-initialize dataSource to point rdfService to the right Resources 954 this._rdfDataSource = new vI_rdfDatasource(this._rdfFileName, true); 909 955 var count = 0; 910 956 while (enumerator.hasMoreElements()) { 911 957 var resource = enumerator.getNext(); count += 1; 912 958 resource.QueryInterface(Components.interfaces.nsIRDFResource); 913 if (vI_notificationBar) vI_notificationBar.dump("## " + count + " : vI_rdfDatasource (" + this._rdfImportDataSource._rdfNS + "): importing " + resource.ValueUTF8 + ".\n");959 if (vI_notificationBar) vI_notificationBar.dump("## " + count + " "); 914 960 var name = this._rdfImportDataSource._getRDFValue(resource, "name") 915 961 var email = this._rdfImportDataSource._getRDFValue(resource, "email") 916 962 var fullName = this._rdfImportDataSource._getRDFValue(resource, "fullName") 917 963 var id = this._rdfImportDataSource._getRDFValue(resource, "id") 918 id = id?relevantIDs[id] :null964 id = id?relevantIDs[id].id:null 919 965 var smtp = this._rdfImportDataSource._getRDFValue(resource, "smtp") 920 smtp = (smtp && smtp != DEFAULT_SMTP_TAG)?relevantSMTPs[smtp]:smtp 921 if (!smtp) smtp = NO_SMTP_TAG; 966 smtp = (smtp && smtp != DEFAULT_SMTP_TAG)?relevantSMTPs[smtp].smtp:smtp 922 967 var extras = new vI_storageExtras(this._rdfImportDataSource, resource); 923 968 var localIdentityData = new vI_identityData(email, fullName, id, smtp, extras) 924 969 925 this._rdfDataSource.updateRDF(name, treeType, localIdentityData, true, true, null, null) 926 if (vI_notificationBar) vI_notificationBar.dump("."); 970 this._rdfDataSource.updateRDF(name, treeType, localIdentityData, false, false, null, null) 971 var resource = this._rdfDataSource._getRDFResourceForVIdentity(name, treeType); 972 if (id) this._rdfDataSource._setRDFValue(resource, "id", id); // localIdentityData can only store valid id's, this one might be a temporary invalid id 973 if (smtp) this._rdfDataSource._setRDFValue(resource, "smtp", smtp); // localIdentityData can only store valid smtp's, this one might be a temporary invalid smtp 927 974 } 928 this._rdfDataSource = null; 929 } 930 if (vI_notificationBar) vI_notificationBar.dump("\n## vI_rdfDatasourceImporter import: import done."); 931 this._rdfImportDataSource = null; 932 933 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: cleaning ID/SMTP storages:"); 934 this._rdfDataSource = new vI_rdfDatasource("virtualIdentity.rdf", true, "http://virtual-id.absorb.it/"); 975 } 976 977 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: removing temporary file " + importRdfDataFile.path + ".\n"); 978 this._rdfImportDataSource = null; importRdfDataFile.remove(false); 979 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: import done.\n"); 980 981 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: cleaning ID/SMTP storages:\n"); 982 this._rdfDataSource = new vI_rdfDatasource(this._rdfFileName, true); 983 984 this._storeMappedIDs(relevantIDs); 935 985 this._rdfDataSource.searchIdentityMismatch(); 986 this._storeMappedSMTPs(relevantSMTPs); 936 987 this._rdfDataSource.searchSmtpMismatch(); 988 937 989 this._rdfDataSource.clean(); 938 990 this._rdfDataSource = null; 939 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: cleaning ID/SMTP storages done."); 991 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: cleaning ID/SMTP storages done.\n"); 992 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter IMPORT DONE.\n"); 940 993 } 941 994 } -
chrome/content/v_identity/vI_storageExtras.js
r045bfd rdd1f45 93 93 this.extras[4] = new vI_storageExtras_sMime_messageEncryption() 94 94 95 if (rdfDatasource) this.loopForRDF(rdfDatasource, resource )95 if (rdfDatasource) this.loopForRDF(rdfDatasource, resource, "get") 96 96 } 97 97 98 98 vI_storageExtras.prototype = { 99 loopForRDF : function(rdfDatasource, resource ) {99 loopForRDF : function(rdfDatasource, resource, type) { 100 100 for( var i = 0; i < this.extras.length; i++ ) { 101 101 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: loopForRDF " + rdfDatasource + "\n"); 102 102 // only if pref set and feature(element available) or for dataEditor 103 if (typeof(gMsgCompose) == "undefined" || !gMsgCompose || this.extras[i].active) 104 this.extras[i].value = rdfDatasource._getRDFValue(resource, this.extras[i].field, this.extras[i].value) 103 if (typeof(gMsgCompose) == "undefined" || !gMsgCompose || this.extras[i].active) { 104 switch (type) { 105 case "get": this.extras[i].value = rdfDatasource._getRDFValue(resource, this.extras[i].field, this.extras[i].value); break; 106 case "set": this.extras[i].value = rdfDatasource._setRDFValue(resource, this.extras[i].field, this.extras[i].value); break; 107 case "unset": this.extras[i].value = rdfDatasource._unsetRDFValue(resource, this.extras[i].field, this.extras[i].value); break; 108 } 109 } 105 110 } 106 111 }, -
chrome/content/v_identity/vI_upgradeOverlay.js
r045bfd rdd1f45 26 26 init: function() { 27 27 var rdfDatasource = new vI_rdfDatasource("virtualIdentity.rdf", true); 28 28 if (rdfDatasource.extUpgradeRequired()) { 29 29 if (!vI_upgrade.quick_upgrade(rdfDatasource.getCurrentExtFileVersion())) 30 30 window.open("chrome://v_identity/content/vI_upgrade.xul",0, … … 35 35 rdfDatasource.storeExtVersion(); 36 36 } 37 rdfDatasource.clean(); 37 rdfDatasource.refreshAccountInfo(); 38 rdfDatasource.clean(); 38 39 39 40 // show error-Console if required
Note: See TracChangeset
for help on using the changeset viewer.