Changeset c65ba0
- Timestamp:
- Oct 4, 2010, 11:32:04 PM (10 years ago)
- Branches:
- ng_0.6, ng_0.8, ng_0.9
- Children:
- 045bfd
- Parents:
- c4e569
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chrome/content/v_identity/vI_rdfDatasource.js
rc4e569 rc65ba0 23 23 * ***** END LICENSE BLOCK ***** */ 24 24 25 function vI_rdfDatasource(rdfFileName, dontRegisterObserver) { 25 26 27 function vI_rdfDatasource(rdfFileName, dontRegisterObserver, rdfNS) { 26 28 this._rdfFileName = rdfFileName; 29 this._rdfNS = rdfNS?rdfNS:"http://virtual-id.absorb.it/"; 27 30 if (this._rdfFileName) this.init(); 28 31 if (!dontRegisterObserver) this.AccountManagerObserver.register(); 29 32 } 30 33 31 vI_rdfDatasource.prototype = { 34 vI_rdfDatasource.prototype = { 35 _rdfVersion : "0.0.5", 32 36 _rdfService : Components.classes["@mozilla.org/rdf/rdf-service;1"] 33 37 .getService(Components.interfaces.nsIRDFService), 34 38 _rdfDataSource : null, 35 39 _rdfFileName : null, 36 _rdfNS : "http://virtual-id.absorb.it/",40 _rdfNS : null, // defaults to "http://virtual-id.absorb.it/" 37 41 _rdfNSStorage : "vIStorage", 38 42 _rdfNSEmail : "vIStorage/email", … … 77 81 78 82 init: function() { 79 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource init .\n");83 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource init with namespace " + this._rdfNS + ".\n"); 80 84 81 85 this._openRdfDataSource(); … … 92 96 93 97 _openRdfDataSource: function() { 94 if (!this._rdfFileName || this._rdfDataSource);98 // if (!this._rdfFileName || this._rdfDataSource); 95 99 var protoHandler = Components.classes["@mozilla.org/network/protocol;1?name=file"] 96 100 .getService(Components.interfaces.nsIFileProtocolHandler) … … 111 115 this._rdfService.GetDataSourceBlocking(fileURI.spec); 112 116 113 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource read rdf from '" + fileURI.spec + "' done." + this._rdfService + "\n");117 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource read rdf from '" + fileURI.spec + "' done." + this._rdfService + "\n"); 114 118 }, 115 119 116 120 _initContainers: function() { 121 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource _initContainers with namespace " + this._rdfNS + ".\n"); 117 122 try { // will possibly fail before upgrade 118 123 var storageRes = this._rdfService … … 169 174 case "0.0.4": 170 175 default: 171 this._createAccountInfoContainers TP();176 this._createAccountInfoContainers(); 172 177 } 173 178 this.storeRDFVersion(); … … 178 183 _transferAllResources : function () { 179 184 if (vI_notificationBar) vI_notificationBar.dump("upgrade: transferAllResources "); 180 var enumerator = this. rdfDataSource.GetAllResources();185 var enumerator = this._rdfDataSource.GetAllResources(); 181 186 while (enumerator && enumerator.hasMoreElements()) { 182 187 var resource = enumerator.getNext(); … … 184 189 185 190 var type; var name; 186 if (resource.ValueUTF8.match(new RegExp(this. rdfNS + this.rdfNSEmail + "/", "i")))191 if (resource.ValueUTF8.match(new RegExp(this._rdfNS + this._rdfNSEmail + "/", "i"))) 187 192 { type = "email"; name = RegExp.rightContext } 188 else if (resource.ValueUTF8.match(new RegExp(this. rdfNS + this.rdfNSNewsgroup + "/", "i")))193 else if (resource.ValueUTF8.match(new RegExp(this._rdfNS + this._rdfNSNewsgroup + "/", "i"))) 189 194 { type = "newsgroup"; name = RegExp.rightContext } 190 else if (resource.ValueUTF8.match(new RegExp(this. rdfNS + this.rdfNSMaillist + "/", "i")))195 else if (resource.ValueUTF8.match(new RegExp(this._rdfNS + this._rdfNSMaillist + "/", "i"))) 191 196 { type = "maillist"; name = RegExp.rightContext } 192 197 else continue; … … 217 222 }, 218 223 // ************** RDF UPGRADE CODE **************************************************** 219 _createAccountInfoContainers TP: function() {224 _createAccountInfoContainers: function() { 220 225 if (vI_notificationBar) vI_notificationBar.dump("upgrade: createAccountInfoContainers \n"); 221 226 var rdfContainerUtils = Components.classes["@mozilla.org/rdf/container-utils;1"]. 222 227 getService(Components.interfaces.nsIRDFContainerUtils); 223 228 224 var accountRes = this. rdfService225 .GetResource(this. rdfNS + this.rdfNSAccounts);226 var identityRes = this. rdfService227 .GetResource(this. rdfNS + this.rdfNSIdentities);228 var smtpRes = this. rdfService229 .GetResource(this. rdfNS + this.rdfNSSMTPservers);229 var accountRes = this._rdfService 230 .GetResource(this._rdfNS + this._rdfNSAccounts); 231 var identityRes = this._rdfService 232 .GetResource(this._rdfNS + this._rdfNSIdentities); 233 var smtpRes = this._rdfService 234 .GetResource(this._rdfNS + this._rdfNSSMTPservers); 230 235 this._setRDFValue(accountRes, "name", "Accounts"); 231 236 this._setRDFValue(identityRes, "name", "Identities"); 232 237 this._setRDFValue(smtpRes, "name", "SMTP-Server"); 233 238 234 rdfContainerUtils.MakeBag(this. rdfDataSource, accountRes);235 rdfContainerUtils.MakeBag(this. rdfDataSource, identityRes);236 rdfContainerUtils.MakeBag(this. rdfDataSource, smtpRes);239 rdfContainerUtils.MakeBag(this._rdfDataSource, accountRes); 240 rdfContainerUtils.MakeBag(this._rdfDataSource, identityRes); 241 rdfContainerUtils.MakeBag(this._rdfDataSource, smtpRes); 237 242 238 243 var accountContainer = Components.classes["@mozilla.org/rdf/container;1"]. … … 240 245 241 246 // initialize container with accountRes 242 accountContainer.Init(this. rdfDataSource, accountRes);247 accountContainer.Init(this._rdfDataSource, accountRes); 243 248 // append all new containers to accountRes 244 249 if (accountContainer.IndexOf(identityRes) == -1) accountContainer.AppendElement(identityRes); … … 254 259 getService(Components.interfaces.nsIRDFContainerUtils); 255 260 256 var storageRes = this. rdfService257 .GetResource(this. rdfNS + this.rdfNSStorage);258 var emailRes = this. rdfService259 .GetResource(this. rdfNS + this.rdfNSEmail);260 var maillistRes = this. rdfService261 .GetResource(this. rdfNS + this.rdfNSMaillist);262 var newsgroupRes = this. rdfService263 .GetResource(this. rdfNS + this.rdfNSNewsgroup);264 var filterRes = this. rdfService265 .GetResource(this. rdfNS + this.rdfNSFilter);261 var storageRes = this._rdfService 262 .GetResource(this._rdfNS + this._rdfNSStorage); 263 var emailRes = this._rdfService 264 .GetResource(this._rdfNS + this._rdfNSEmail); 265 var maillistRes = this._rdfService 266 .GetResource(this._rdfNS + this._rdfNSMaillist); 267 var newsgroupRes = this._rdfService 268 .GetResource(this._rdfNS + this._rdfNSNewsgroup); 269 var filterRes = this._rdfService 270 .GetResource(this._rdfNS + this._rdfNSFilter); 266 271 this._setRDFValue(emailRes, "name", "E-Mail"); 267 272 this._setRDFValue(maillistRes, "name", "Mailing-List"); … … 269 274 this._setRDFValue(filterRes, "name", "Filter"); 270 275 271 rdfContainerUtils.MakeBag(this. rdfDataSource, storageRes);272 rdfContainerUtils.MakeBag(this. rdfDataSource, emailRes);273 rdfContainerUtils.MakeBag(this. rdfDataSource, maillistRes);274 rdfContainerUtils.MakeBag(this. rdfDataSource, newsgroupRes);276 rdfContainerUtils.MakeBag(this._rdfDataSource, storageRes); 277 rdfContainerUtils.MakeBag(this._rdfDataSource, emailRes); 278 rdfContainerUtils.MakeBag(this._rdfDataSource, maillistRes); 279 rdfContainerUtils.MakeBag(this._rdfDataSource, newsgroupRes); 275 280 // use a sequence for the filters, order does matter 276 rdfContainerUtils.MakeSeq(this. rdfDataSource, filterRes);281 rdfContainerUtils.MakeSeq(this._rdfDataSource, filterRes); 277 282 278 283 var container = Components.classes["@mozilla.org/rdf/container;1"]. … … 280 285 281 286 // initialize container with storageRes 282 container.Init(this. rdfDataSource, storageRes);287 container.Init(this._rdfDataSource, storageRes); 283 288 // append all new containers to storageRes 284 289 if (container.IndexOf(emailRes) == -1) container.AppendElement(emailRes); … … 307 312 this._setRDFValue( 308 313 this._rdfService.GetResource(this._rdfNS + "virtualIdentity"), "rdfVersion", 309 this. rdfVersion);314 this._rdfVersion); 310 315 this._flush(); 311 316 }, … … 360 365 }, 361 366 362 searchIdentityMismatch : function() { 363 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchIdentityMismatch\n"); 364 367 getRelevantIDs : function() { 365 368 var relevantIDs = new Object(); 366 var mismatchIDs = [];367 368 369 // search relevant Identities 369 370 for each (treeType in Array("email", "maillist", "newsgroup", "filter")) { … … 378 379 } 379 380 } 381 return relevantIDs; 382 }, 383 384 searchIdentityMismatch : function() { 385 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchIdentityMismatch\n"); 386 387 var relevantIDs = this.getRelevantIDs(); 388 var mismatchIDs = []; 380 389 381 390 var AccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"] … … 426 435 }, 427 436 428 searchSmtpMismatch : function() { 429 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchSmtpMismatch\n"); 430 437 getRelevantSMTPs : function() { 431 438 var relevantSMTPs = new Object(); 432 var mismatchSMTPs = [];433 434 439 // search relevant SMTPs 435 440 for each (treeType in Array("email", "maillist", "newsgroup", "filter")) { … … 444 449 } 445 450 } 451 return relevantSMTPs; 452 }, 453 454 searchSmtpMismatch : function() { 455 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchSmtpMismatch\n"); 456 457 var relevantSMTPs = this.getRelevantSMTPs(); 458 var mismatchSMTPs = []; 446 459 447 460 var SmtpService = Components.classes["@mozilla.org/messengercompose/smtp;1"] … … 493 506 function storeSmtp(server, parent) { 494 507 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: storeAccounts smtp store id " + server.key + "\n"); 495 var resource = parent._rdfService.GetResource( this._rdfNS + this._rdfNSSMTPservers + "/" + server.key);508 var resource = parent._rdfService.GetResource(parent._rdfNS + parent._rdfNSSMTPservers + "/" + server.key); 496 509 parent._setRDFValue(resource, "label", (server.description?server.description:server.hostname)); 497 510 parent._setRDFValue(resource, "hostname", server.hostname); … … 534 547 }, 535 548 536 import : function(rdfFileName) {537 var filePicker = Components.classes["@mozilla.org/filepicker;1"]538 .createInstance(Components.interfaces.nsIFilePicker);539 540 filePicker.init(window, "", Components.interfaces.nsIFilePicker.modeOpen);541 filePicker.appendFilter("RDF Files","*.rdf");542 filePicker.appendFilters(Components.interfaces.nsIFilePicker.filterText | Components.interfaces.nsIFilePicker.filterAll );543 544 if (filePicker.show() == Components.interfaces.nsIFilePicker.returnOK) {545 // init local Datasource546 this._rdfFileName = rdfFileName; this.init();547 548 var importRdfDataFile = Components.classes["@mozilla.org/file/local;1"]549 .createInstance(Components.interfaces.nsILocalFile);550 var file = Components.classes["@mozilla.org/file/directory_service;1"]551 .getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);552 var delimiter = (file.path.match(/\\/))?"\\":"/";553 rdfDataFile.initWithPath(file.path + delimiter + this._rdfFileName + "_import");554 555 filePicker.file.copyTo(importRdfDataFile.parent,importRdfDataFile.leafName);556 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource import: copied file from " + filePicker.path + " to " + importRdfDataFile.path + "'\n");557 558 import_rdfDatasource = new vI_rdfDatasource(importRdfDataFile.leafName);559 // --- do something with the file here ---560 }561 },562 563 549 _getRDFResourceForVIdentity : function (recDescription, recType) { 564 550 if (!this._rdfDataSource) return null; … … 575 561 } 576 562 return this._rdfService.GetResource(this._rdfNS + _rdfNSRecType + "/" + recDescription); 563 564 577 565 }, 578 566 579 567 removeVIdentityFromRDF : function (resource, recType) { 580 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: removeVIdentityFromRDF " + resource.ValueUTF8 + ".\n");568 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: removeVIdentityFromRDF " + resource.ValueUTF8 + ".\n"); 581 569 this._unsetRDFValue(resource, "email", this._getRDFValue(resource, "email")) 582 570 this._unsetRDFValue(resource, "fullName", this._getRDFValue(resource, "fullName")) … … 585 573 this._unsetRDFValue(resource, "name", this._getRDFValue(resource, "name")) 586 574 587 588 extras.loopForRDF(this._unsetRDFValue, resource);589 575 var extras = new vI_storageExtras(this, resource); 576 extras.loopForRDF(this, resource, "unset"); 577 this.getContainer(recType).RemoveElement(resource, true); 590 578 }, 591 579 … … 595 583 var name = this._rdfService.GetLiteral(value?value:""); 596 584 var target = this._rdfDataSource.GetTarget(resource, predicate, true); 597 if (target instanceof Components.interfaces.nsIRDFLiteral) 585 if (target instanceof Components.interfaces.nsIRDFLiteral) { 598 586 this._rdfDataSource.Unassert(resource, predicate, name, true); 587 return null; 588 } 589 else return value; 599 590 }, 600 591 … … 713 704 714 705 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"); 707 715 708 // if (!localIdentityData.email) { 716 709 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: updateRDF: no Sender-email for Recipient, aborting.\n"); 717 710 // return; 718 711 // } 719 if ( recDescription.length == 0) return;712 if (!recDescription || recDescription.length == 0) return; 720 713 721 714 if (!prevRecDescription) prevRecDescription = recDescription; … … 728 721 var position = this.getContainer(recType).IndexOf(resource); // check for index in new recType 729 722 this.removeVIdentityFromRDF(resource, prevRecType); 730 731 723 724 resource = this._getRDFResourceForVIdentity(recDescription, recType); 732 725 733 726 this._setRDFValue(resource, "email", localIdentityData.email); … … 739 732 this._setRDFValue(resource, "smtp", localIdentityData.smtp.key); 740 733 else this._unsetRDFValue(resource, "smtp", this._getRDFValue(resource, "smtp")) 741 742 743 localIdentityData.extras.loopForRDF(this._setRDFValue, resource);734 this._setRDFValue(resource, "name", recDescription); 735 736 localIdentityData.extras.loopForRDF(this, resource, "set"); 744 737 745 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource : updateRDF " + resource.ValueUTF8 + " added.\n");746 if (position != -1) this.getContainer(recType).InsertElementAt(resource, position, false);738 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource (" + this._rdfFileName + "): updateRDF add " + resource.ValueUTF8 + " at position " + position + ".\n"); 739 if (position != -1) this.getContainer(recType).InsertElementAt(resource, position, true); 747 740 else this.getContainer(recType).AppendElement(resource); 748 741 }, … … 750 743 _setRDFValue : function (resource, field, value) { 751 744 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: _setRDFValue " + resource.ValueUTF8 + " " + field + " " + value + ".\n"); 752 if (!value) return ; // return if some value was not set.745 if (!value) return value; // return if some value was not set. 753 746 // if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource _setRDFValue " + this._rdfService + " " + this._rdfDataSource + "\n"); 754 747 var predicate = this._rdfService.GetResource(this._rdfNS + "rdf#" + field); … … 759 752 this._rdfDataSource.Change(resource, predicate, target, name); 760 753 else this._rdfDataSource.Assert(resource, predicate, name, true); 754 return value; 761 755 }, 762 756 … … 789 783 } 790 784 } 785 786 787 function vI_rdfDatasourceImporter(rdfFileName) { 788 this._rdfFileName = rdfFileName; 789 if (this._rdfFileName) this.import(); 790 } 791 792 vI_rdfDatasourceImporter.prototype = { 793 _rdfDataSource : null, 794 _rdfFileName : null, 795 _rdfImportDataSource : null, 796 797 _getMatchingIdentity : function(name, email, fullName) { 798 var AccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"] 799 .getService(Components.interfaces.nsIMsgAccountManager); 800 for (let i = 0; i < AccountManager.accounts.Count(); i++) { 801 var account = AccountManager.accounts.QueryElementAt(i, Components.interfaces.nsIMsgAccount); 802 for (let j = 0; j < account.identities.Count(); j++) { 803 var identity = account.identities.QueryElementAt(j, Components.interfaces.nsIMsgIdentity); 804 if (name == identity.identityName || (fullName == identity.fullName && email == identity.email)) return identity.key; 805 } 806 } 807 return null; 808 }, 809 810 _getMatchingSMTP : function(label, hostname, username) { 811 var servers = Components.classes["@mozilla.org/messengercompose/smtp;1"] 812 .getService(Components.interfaces.nsISmtpService).smtpServers; 813 if (typeof(servers.Count) == "undefined") // TB 3.x 814 while (servers && servers.hasMoreElements()) { 815 var server = servers.getNext(); 816 if (server instanceof Components.interfaces.nsISmtpServer && !server.redirectorType) 817 if (label == (server.description?server.description:server.hostname) || (hostname == server.hostname && username == server.username)) 818 return server.key; 819 } 820 else // TB 2.x 821 for (var i=0 ; i<servers.Count(); i++) 822 if (label == (server.description?server.description:server.hostname) || (hostname == server.hostname && username == server.username)) 823 return server.key; 824 return null; 825 }, 826 827 import : function() { 828 var filePicker = Components.classes["@mozilla.org/filepicker;1"] 829 .createInstance(Components.interfaces.nsIFilePicker); 830 831 filePicker.init(window, "", Components.interfaces.nsIFilePicker.modeOpen); 832 filePicker.appendFilter("RDF Files","*.rdf"); 833 filePicker.appendFilters(Components.interfaces.nsIFilePicker.filterText | Components.interfaces.nsIFilePicker.filterAll ); 834 835 if (filePicker.show() == Components.interfaces.nsIFilePicker.returnOK) { 836 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: preparation:\n"); 837 838 var importRdfDataFile = Components.classes["@mozilla.org/file/local;1"] 839 .createInstance(Components.interfaces.nsILocalFile); 840 var file = Components.classes["@mozilla.org/file/directory_service;1"] 841 .getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile); 842 var delimiter = (file.path.match(/\\/))?"\\":"/"; 843 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(); 871 872 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 875 // 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 } 900 901 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: preparation done.\n"); 902 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: starting import:"); 903 904 for each (treeType in Array("email", "maillist", "newsgroup", "filter")) { 905 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"); 907 var enumerator = container.GetElements(); 908 this._rdfDataSource = new vI_rdfDatasource("virtualIdentity.rdf", true, "http://virtual-id.absorb.it/"); 909 var count = 0; 910 while (enumerator.hasMoreElements()) { 911 var resource = enumerator.getNext(); count += 1; 912 resource.QueryInterface(Components.interfaces.nsIRDFResource); 913 if (vI_notificationBar) vI_notificationBar.dump("## " + count + ": vI_rdfDatasource (" + this._rdfImportDataSource._rdfNS + "): importing " + resource.ValueUTF8 + ".\n"); 914 var name = this._rdfImportDataSource._getRDFValue(resource, "name") 915 var email = this._rdfImportDataSource._getRDFValue(resource, "email") 916 var fullName = this._rdfImportDataSource._getRDFValue(resource, "fullName") 917 var id = this._rdfImportDataSource._getRDFValue(resource, "id") 918 id = id?relevantIDs[id]:null 919 var smtp = this._rdfImportDataSource._getRDFValue(resource, "smtp") 920 smtp = (smtp && smtp != DEFAULT_SMTP_TAG)?relevantSMTPs[smtp]:smtp 921 if (!smtp) smtp = NO_SMTP_TAG; 922 var extras = new vI_storageExtras(this._rdfImportDataSource, resource); 923 var localIdentityData = new vI_identityData(email, fullName, id, smtp, extras) 924 925 this._rdfDataSource.updateRDF(name, treeType, localIdentityData, true, true, null, null) 926 if (vI_notificationBar) vI_notificationBar.dump("."); 927 } 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/"); 935 this._rdfDataSource.searchIdentityMismatch(); 936 this._rdfDataSource.searchSmtpMismatch(); 937 this._rdfDataSource.clean(); 938 this._rdfDataSource = null; 939 if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasourceImporter import: cleaning ID/SMTP storages done."); 940 } 941 } 942 }
Note: See TracChangeset
for help on using the changeset viewer.