changeset 84:915e41848f6d

rename universalID to externalID
author Myk Melez <myk@mozilla.org>
date Fri, 16 May 2008 10:42:36 -0700
parents 7ee1176fa699
children f5161c834622
files extension/modules/datastore.js extension/modules/feed.js extension/modules/service.js
diffstat 3 files changed, 30 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/extension/modules/datastore.js	Thu May 15 19:03:18 2008 -0700
+++ b/extension/modules/datastore.js	Fri May 16 10:42:36 2008 -0700
@@ -27,15 +27,14 @@
   _dbSchema: {
     // Note: the timestamp is stored as JavaScript milliseconds since epoch.
 
-    // Note: the universalID is a unique identifier established by the source
+    // Note: the externalID is a unique identifier established by the source
     // of the message which remains constant across message transfer points
     // and destinations.  For feeds this is the entry ID; for email messages
     // it's the message ID.
 
     // FIXME: make the datastore support multiple authors.
     // FIXME: support labeling the subject as HTML or another content type.
-    // FIXME: make universalID be called externalID instead.
-    // FIXME: index by universalID to make lookups (f.e. when checking if we
+    // FIXME: index by externalID to make lookups (f.e. when checking if we
     // already have a message) and updates (f.e. when setting current) faster.
 
     tables: {
@@ -56,7 +55,7 @@
         columns: [
           "id INTEGER PRIMARY KEY",
           "sourceID INTEGER NOT NULL REFERENCES sources(id)",
-          "universalID TEXT",
+          "externalID TEXT",
           "subject TEXT",
           "author TEXT",
           "timestamp INTEGER",
@@ -260,15 +259,15 @@
 
   get _selectHasMessageStatement() {
     let statement = this.createStatement(
-      "SELECT 1 FROM messages WHERE universalID = :universalID"
+      "SELECT 1 FROM messages WHERE externalID = :externalID"
     );
     this.__defineGetter__("_selectHasMessageStatement", function() { return statement });
     return this._selectHasMessageStatement;
   },
 
-  selectHasMessage: function(aUniversalID) {
+  selectHasMessage: function(aExternalID) {
     try {
-      this._selectHasMessageStatement.params.universalID = aUniversalID;
+      this._selectHasMessageStatement.params.externalID = aExternalID;
       if (this._selectHasMessageStatement.step())
         return true;
     }
@@ -281,7 +280,7 @@
 
   get _selectInternalIDForExternalIDStatement() {
     let statement = this.createStatement(
-      "SELECT id FROM messages WHERE universalID = :externalID"
+      "SELECT id FROM messages WHERE externalID = :externalID"
     );
     this.__defineGetter__("_selectInternalIDForExternalIDStatement", function() { return statement });
     return this._selectInternalIDForExternalIDStatement;
@@ -304,8 +303,8 @@
 
   get _insertMessageStatement() {
     let statement = this.createStatement(
-      "INSERT INTO messages(sourceID, universalID, subject, author, timestamp, link) \
-       VALUES (:sourceID, :universalID, :subject, :author, :timestamp, :link)"
+      "INSERT INTO messages(sourceID, externalID, subject, author, timestamp, link) \
+       VALUES (:sourceID, :externalID, :subject, :author, :timestamp, :link)"
     );
     this.__defineGetter__("_insertMessageStatement", function() { return statement });
     return this._insertMessageStatement;
@@ -315,7 +314,7 @@
    * Insert a record into the messages table.
    * 
    * @param aSourceID    {integer} the record ID of the message source
-   * @param aUniversalID {string}  the universal ID of the message
+   * @param aExternalID  {string}  the external ID of the message
    * @param aSubject     {string}  the title of the message
    * @param aAuthor      {string}  the author of the message
    * @param aTimestamp   {Date}    the date/time at which the message was sent
@@ -324,9 +323,9 @@
    *
    * @returns {integer} the ID of the newly-created record
    */
-  insertMessage: function(aSourceID, aUniversalID, aSubject, aAuthor, aTimestamp, aLink) {
+  insertMessage: function(aSourceID, aExternalID, aSubject, aAuthor, aTimestamp, aLink) {
     this._insertMessageStatement.params.sourceID = aSourceID;
-    this._insertMessageStatement.params.universalID = aUniversalID;
+    this._insertMessageStatement.params.externalID = aExternalID;
     this._insertMessageStatement.params.subject = aSubject;
     this._insertMessageStatement.params.author = aAuthor;
     this._insertMessageStatement.params.timestamp = aTimestamp;
--- a/extension/modules/feed.js	Thu May 15 19:03:18 2008 -0700
+++ b/extension/modules/feed.js	Fri May 16 10:42:36 2008 -0700
@@ -87,22 +87,22 @@
         // been retrieved.  If we can't figure out the entry's ID, then we skip
         // the entry, since its ID is the only way for us to know whether or not
         // it has already been retrieved.
-        let universalID;
+        let externalID;
         try {
-          universalID = entry.id || this.generateID(entry);
+          externalID = entry.id || this.generateID(entry);
         }
         catch(ex) {
           this._log.warn(this.title + " couldn't retrieve a message: " + ex);
           continue;
         }
 
-        let internalID = this.getInternalIDForExternalID(universalID);
+        let internalID = this.getInternalIDForExternalID(externalID);
 
         if (internalID)
-          this._log.info(this.title + " has message " + universalID);
+          this._log.info(this.title + " has message " + externalID);
         else {
-          this._log.info(this.title + " adding message " + universalID);
-          internalID = this.addMessage(entry, universalID);
+          this._log.info(this.title + " adding message " + externalID);
+          internalID = this.addMessage(entry, externalID);
         }
 
         currentMessages.push(internalID);
@@ -158,9 +158,9 @@
    * Add a message to the datastore for the given feed entry.
    *
    * @param aEntry        {nsIFeedEntry}  the feed entry
-   * @param aUniversalID  {string}        the universal ID of the feed entry
+   * @param aExternalID   {string}        the external ID of the feed entry
    */
-  addMessage: function(aEntry, aUniversalID) {
+  addMessage: function(aEntry, aExternalID) {
     // Combine the first author's name and email address into a single string
     // that we'll use as the author of the message.
     let author = null;
@@ -184,10 +184,10 @@
     // either "html", "xhtml", or "text", into an Internet media type.
     let contentType = aEntry.content ? this.contentTypes[aEntry.content.type] : null;
     let contentText = aEntry.content ? aEntry.content.text : null;
-    let messageID = this.addSimpleMessage(this.id, aUniversalID,
-                                                  aEntry.title.text, author,
-                                                  timestamp, aEntry.link,
-                                                  contentText, contentType);
+    let messageID = this.addSimpleMessage(this.id, aExternalID,
+                                          aEntry.title.text, author,
+                                          timestamp, aEntry.link,
+                                          contentText, contentType);
 
     // Add metadata.
     let fields = aEntry.QueryInterface(Ci.nsIFeedContainer).
@@ -296,7 +296,7 @@
    * Add a message with a single part to the datastore.
    *
    * @param aSourceID    {integer} the record ID of the message source
-   * @param aUniversalID {string}  the universal ID of the message
+   * @param aExternalID  {string}  the external ID of the message
    * @param aSubject     {string}  the title of the message
    * @param aAuthor      {string}  the author of the message
    * @param aTimestamp   {Date}    the date/time at which the message was sent
@@ -312,7 +312,7 @@
    * 
    * @returns {integer} the internal ID of the newly-created message
    */
-  addSimpleMessage: function(aSourceID, aUniversalID, aSubject, aAuthor,
+  addSimpleMessage: function(aSourceID, aExternalID, aSubject, aAuthor,
                              aTimestamp, aLink, aContent, aContentType) {
     // Convert the timestamp to milliseconds-since-epoch, which is how we store
     // it in the datastore.
@@ -323,7 +323,7 @@
     let link = aLink ? aLink.spec : null;
 
     let messageID =
-      SnowlDatastore.insertMessage(aSourceID, aUniversalID, aSubject, aAuthor,
+      SnowlDatastore.insertMessage(aSourceID, aExternalID, aSubject, aAuthor,
                                    timestamp, link);
 
     if (aContent)
--- a/extension/modules/service.js	Thu May 15 19:03:18 2008 -0700
+++ b/extension/modules/service.js	Fri May 16 10:42:36 2008 -0700
@@ -250,12 +250,12 @@
   /**
    * Determine whether or not the datastore contains the message with the given ID.
    *
-   * @param aUniversalID {string}  the universal ID of the message
+   * @param aExternalID {string}  the external ID of the message
    *
    * @returns {boolean} whether or not the datastore contains the message
    */
-  hasMessage: function(aUniversalID) {
-    return SnowlDatastore.selectHasMessage(aUniversalID);
+  hasMessage: function(aExternalID) {
+    return SnowlDatastore.selectHasMessage(aExternalID);
   }
 
 };