Changeset dd1f45


Ignore:
Timestamp:
Oct 5, 2010, 1:54:59 PM (10 years ago)
Author:
rene <just@…>
Branches:
ng_0.6, ng_0.8, ng_0.9
Children:
0852d9
Parents:
045bfd
Message:

cleanup and finalization of rdf-import

Location:
chrome/content/v_identity
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/vI_context.xul

    r045bfd rdd1f45  
    6565                        <menuitem label="&vident.vI_Menu.DataEditor.label;"
    6666                            oncommand="window.open('chrome://v_identity/content/vI_rdfDataTree.xul', '', 'chrome, dialog, resizable=yes');" />
    67                         <menuitem label="&importCmd.label;" accesskey="&importCmd.accesskey;" oncommand="vI_rdfDatasource = new vI_rdfDatasource(); vI_rdfDatasource.import('virtualIdentity.rdf')"/>
    68                         <menuitem label="&exportCmd.label;" accesskey="&exportCmd.accesskey;" oncommand="vI_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')"/>
    6969                    </menupopup>
    7070                </menu>
  • chrome/content/v_identity/vI_prefDialog.xul

    r045bfd rdd1f45  
    574574                <spacer class="paragraph"/>
    575575                <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="vI_rdfDatasource = new vI_rdfDatasource(); vI_rdfDatasource.import('virtualIdentity.rdf')" />
    577                 <button id="VIdent_identity.storage.export" label="&vI_prefDialog.storage.export;" oncommand="vI_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')" />
    578578                </groupbox>
    579579            </tabpanel>
  • chrome/content/v_identity/vI_rdfAccountMismatchDialog.js

    r045bfd rdd1f45  
    5252            vI_rdfAccountMismatchDialog.mismatchItems[i].key = document.getElementById("mismatchLine_" + i).key
    5353        }
    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);
    5656    }
    5757}
  • chrome/content/v_identity/vI_rdfDataTree.xul

    r045bfd rdd1f45  
    115115        <menu id="tasksMenu" label="&tasksMenu.label;" accesskey="&tasksMenu.accesskey;">
    116116        <menupopup>
    117             <menuitem label="&importCmd.label;" accesskey="&importCmd.accesskey;" oncommand="vI_rdfDatasource = new vI_rdfDatasource(); vI_rdfDatasource.import('virtualIdentity.rdf')"/>
    118             <menuitem label="&exportCmd.label;" accesskey="&exportCmd.accesskey;" oncommand="vI_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')"/>
    119119        </menupopup>
    120120        </menu>
  • chrome/content/v_identity/vI_rdfDatasource.js

    r045bfd rdd1f45  
    2525
    2626
    27 function vI_rdfDatasource(rdfFileName, dontRegisterObserver, rdfNS) {
     27function vI_rdfDatasource(rdfFileName, dontRegisterObserver) {
    2828    this._rdfFileName = rdfFileName;
    29     this._rdfNS = rdfNS?rdfNS:"http://virtual-id.absorb.it/";
    3029    if (this._rdfFileName) this.init();
    3130    if (!dontRegisterObserver) this.AccountManagerObserver.register();
     
    3837    _rdfDataSource :    null,
    3938    _rdfFileName :      null,
    40     _rdfNS :            null,           //   defaults to "http://virtual-id.absorb.it/"
     39    _rdfNS :            "http://virtual-id.absorb.it/",
    4140    _rdfNSStorage :     "vIStorage",
    4241    _rdfNSEmail :       "vIStorage/email",
     
    8180
    8281    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");
    8483
    8584        this._openRdfDataSource();
     
    9190        this.storeRDFVersion();
    9291           
    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");
    9594    },
    9695   
     
    110109        var fileURI = protoHandler.newFileURI(newFile);
    111110
    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");
    113112
    114113        this._rdfDataSource =
     
    119118   
    120119    _initContainers: function() {
    121         if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource _initContainers with namespace " + this._rdfNS + ".\n");
    122120        try {   // will possibly fail before upgrade
    123121            var storageRes = this._rdfService
     
    383381   
    384382    searchIdentityMismatch : function() {
    385         if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchIdentityMismatch\n");
     383        if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchIdentityMismatch");
    386384
    387385        var relevantIDs = this.getRelevantIDs();
     
    391389            .getService(Components.interfaces.nsIMsgAccountManager);
    392390        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            }
    394401            var resource = this._rdfService.GetResource(this._rdfNS + this._rdfNSIdentities + "/" + id);
    395402            var rdfIdentityName = this._getRDFValue(resource, "identityName");
    396403            var rdfEmail = this._getRDFValue(resource, "email");
    397404            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: "" } )
    400408        }
    401409        if (mismatchIDs.length > 0) {
    402             if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchIdentityMismatch found mismatches on id(s).\n");
     410            if (vI_notificationBar) vI_notificationBar.dump(" found mismatches on id(s).\n");
    403411           
    404412            window.openDialog("chrome://v_identity/content/vI_rdfAccountMismatchDialog.xul",0,
    405413                    "chrome, dialog, modal, alwaysRaised, resizable=yes", "identity", mismatchIDs,
    406                     /* callback: */ this.repairAccountMismatch).focus();
     414                    /* callback chance: */ this).focus();
    407415            return true;
    408416        }
    409417        else {
    410             if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchIdentityMismatch found no mismatch\n");
     418            if (vI_notificationBar) vI_notificationBar.dump(" found no mismatch\n");
    411419            return false;
    412420        }
     
    414422   
    415423    repairAccountMismatch : function(type, mismatchItems) {
    416         if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: repairAccountMismatch\n");
    417424        var keyField = (type == "identity")?"id":"smtp" // field to change is 'id' or 'smtp' dependent on type
    418425        for (var i = 0; i < mismatchItems.length; i++) {
     
    453460   
    454461    searchSmtpMismatch : function() {
    455         if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchSmtpMismatch\n");
     462        if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchSmtpMismatch");
    456463
    457464        var relevantSMTPs = this.getRelevantSMTPs();
    458465        var mismatchSMTPs = [];
    459466       
    460         var SmtpService = Components.classes["@mozilla.org/messengercompose/smtp;1"]
    461             .getService(Components.interfaces.nsISmtpService);
    462467        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                }
    464486            var resource = this._rdfService.GetResource(this._rdfNS + this._rdfNSSMTPservers + "/" + smtp);
    465487            var rdfSMTPlabel = this._getRDFValue(resource, "label");
    466488            var rdfHostname = this._getRDFValue(resource, "hostname");
    467489            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)
    469491                    mismatchSMTPs.push( { oldkey: smtp, label : rdfSMTPlabel, ext1: rdfHostname, ext2: rdfUsername, count: relevantSMTPs[smtp], key: "" } )
    470492        }
    471493        if (mismatchSMTPs.length > 0) {
    472             if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchSmtpMismatch found mismatches on smtp(s).\n");
     494            if (vI_notificationBar) vI_notificationBar.dump(" found mismatches on smtp(s).\n");
    473495            window.openDialog("chrome://v_identity/content/vI_rdfAccountMismatchDialog.xul",0,
    474496                    "chrome, dialog, modal, alwaysRaised, resizable=yes", "smtp", mismatchSMTPs,
    475                     /* callback: */ this.repairAccountMismatch).focus();
     497                    /* callback: */ this).focus();
    476498            return true;
    477499        }
    478500        else {
    479             if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: searchSmtpMismatch found no mismatch\n");
     501            if (vI_notificationBar) vI_notificationBar.dump(" found no mismatch\n");
    480502            return false;
    481503        }
     
    535557        filePicker.appendFilter("RDF Files","*.rdf");
    536558       
    537         if (filePicker.show() == Components.interfaces.nsIFilePicker.returnOK) {
     559        if (filePicker.show() != Components.interfaces.nsIFilePicker.returnCancel) {
    538560            var rdfDataFile = Components.classes["@mozilla.org/file/local;1"]
    539561                .createInstance(Components.interfaces.nsILocalFile);
     
    704726
    705727    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");
    707729       
    708730//      if (!localIdentityData.email) {
     
    717739        var resource = this._getRDFResourceForVIdentity(prevRecDescription, prevRecType);
    718740        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");
    720742       
    721743        var position = this.getContainer(recType).IndexOf(resource); // check for index in new recType
     
    736758        localIdentityData.extras.loopForRDF(this, resource, "set");
    737759       
    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");
    739761        if (position != -1) this.getContainer(recType).InsertElementAt(resource, position, true);
    740762        else this.getContainer(recType).AppendElement(resource);
     
    742764
    743765    _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");
    745767        if (!value) return value; // return if some value was not set.
    746768//      if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource _setRDFValue " + this._rdfService + " " + this._rdfDataSource + "\n");
     
    784806}
    785807
    786 
     808// create with name of the file to import into
    787809function vI_rdfDatasourceImporter(rdfFileName) {
    788810    this._rdfFileName = rdfFileName;
     
    791813
    792814vI_rdfDatasourceImporter.prototype = {
     815    _rdfService :       Components.classes["@mozilla.org/rdf/rdf-service;1"]
     816                            .getService(Components.interfaces.nsIRDFService),
    793817    _rdfDataSource :    null,
    794818    _rdfFileName :      null,
     
    825849    },
    826850   
     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   
    827915    import : function() {
    828916        var filePicker = Components.classes["@mozilla.org/filepicker;1"]
     
    834922       
    835923        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");
    837925           
    838926            var importRdfDataFile = Components.classes["@mozilla.org/file/local;1"]
     
    842930            var delimiter = (file.path.match(/\\/))?"\\":"/";
    843931            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);
    871933
    872934            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");
    874935           
    875936            // 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();
    900942           
    901943            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");
    903945
    904946            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);
    905949                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");
    907952                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);
    909955                var count = 0;
    910956                while (enumerator.hasMoreElements()) {
    911957                    var resource = enumerator.getNext(); count += 1;
    912958                    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 + " ");
    914960                    var name = this._rdfImportDataSource._getRDFValue(resource, "name")
    915961                    var email = this._rdfImportDataSource._getRDFValue(resource, "email")
    916962                    var fullName = this._rdfImportDataSource._getRDFValue(resource, "fullName")
    917963                    var id = this._rdfImportDataSource._getRDFValue(resource, "id")
    918                     id = id?relevantIDs[id]:null
     964                    id = id?relevantIDs[id].id:null
    919965                    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
    922967                    var extras = new vI_storageExtras(this._rdfImportDataSource, resource);
    923968                    var localIdentityData = new vI_identityData(email, fullName, id, smtp, extras)
    924969                   
    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
    927974                }
    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);
    935985            this._rdfDataSource.searchIdentityMismatch();
     986            this._storeMappedSMTPs(relevantSMTPs);
    936987            this._rdfDataSource.searchSmtpMismatch();
     988           
    937989            this._rdfDataSource.clean();
    938990            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");
    940993        }
    941994    }
  • chrome/content/v_identity/vI_storageExtras.js

    r045bfd rdd1f45  
    9393        this.extras[4] = new vI_storageExtras_sMime_messageEncryption()
    9494
    95     if (rdfDatasource) this.loopForRDF(rdfDatasource, resource)
     95    if (rdfDatasource) this.loopForRDF(rdfDatasource, resource, "get")
    9696}
    9797
    9898vI_storageExtras.prototype = {
    99     loopForRDF : function(rdfDatasource, resource) {
     99    loopForRDF : function(rdfDatasource, resource, type) {
    100100        for( var i = 0; i < this.extras.length; i++ ) {
    101101//          if (vI_notificationBar) vI_notificationBar.dump("## vI_rdfDatasource: loopForRDF " + rdfDatasource + "\n");
    102102            // 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            }
    105110        }
    106111    },
  • chrome/content/v_identity/vI_upgradeOverlay.js

    r045bfd rdd1f45  
    2626    init: function() {
    2727        var rdfDatasource = new vI_rdfDatasource("virtualIdentity.rdf", true);
    28         if (rdfDatasource.extUpgradeRequired()) {
     28        if (rdfDatasource.extUpgradeRequired()) {
    2929            if (!vI_upgrade.quick_upgrade(rdfDatasource.getCurrentExtFileVersion()))
    3030                window.open("chrome://v_identity/content/vI_upgrade.xul",0,
     
    3535            rdfDatasource.storeExtVersion();
    3636        }
    37         rdfDatasource.clean();
     37        rdfDatasource.refreshAccountInfo();
     38        rdfDatasource.clean();
    3839       
    3940        // show error-Console if required
Note: See TracChangeset for help on using the changeset viewer.