~ubuntu-branches/ubuntu/trusty/enigmail/trusty-security

« back to all changes in this revision

Viewing changes to services/sync/Weave.js

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2011-08-12 12:25:06 UTC
  • mfrom: (0.12.4 upstream)
  • Revision ID: package-import@ubuntu.com-20110812122506-zko6c7zfexvyg71q
Tags: 2:1.2.1-0ubuntu1
* New upstream release
* Drop fix_install_rdf_xml_errors.diff - fixed upstream
* Refresh port_to_latest_thunderbird.diff
* Add a proper get-orig-source target which pulls the build system from
  lp:~mozillateam/mozilla-build-system/beta, now that we don't have the old
  build-system.tar.gz from xulrunner

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ***** BEGIN LICENSE BLOCK *****
2
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
 
 *
4
 
 * The contents of this file are subject to the Mozilla Public License Version
5
 
 * 1.1 (the "License"); you may not use this file except in compliance with
6
 
 * the License. You may obtain a copy of the License at
7
 
 * http://www.mozilla.org/MPL/
8
 
 *
9
 
 * Software distributed under the License is distributed on an "AS IS" basis,
10
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
 
 * for the specific language governing rights and limitations under the
12
 
 * License.
13
 
 *
14
 
 * The Original Code is Weave.
15
 
 *
16
 
 * The Initial Developer of the Original Code is Mozilla.
17
 
 * Portions created by the Initial Developer are Copyright (C) 2008
18
 
 * the Initial Developer. All Rights Reserved.
19
 
 *
20
 
 * Contributor(s):
21
 
 *  Dan Mills <thunder@mozilla.com>
22
 
 *
23
 
 * Alternatively, the contents of this file may be used under the terms of
24
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
25
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
27
 
 * of those above. If you wish to allow use of your version of this file only
28
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
29
 
 * use your version of this file under the terms of the MPL, indicate your
30
 
 * decision by deleting the provisions above and replace them with the notice
31
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
32
 
 * the provisions above, a recipient may use your version of this file under
33
 
 * the terms of any one of the MPL, the GPL or the LGPL.
34
 
 *
35
 
 * ***** END LICENSE BLOCK ***** */
36
 
 
37
 
const Cc = Components.classes;
38
 
const Ci = Components.interfaces;
39
 
const Cu = Components.utils;
40
 
 
41
 
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
42
 
 
43
 
function WeaveService() {
44
 
  this.wrappedJSObject = this;
45
 
}
46
 
WeaveService.prototype = {
47
 
  classID: Components.ID("{74b89fb0-f200-4ae8-a3ec-dd164117f6de}"),
48
 
 
49
 
  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
50
 
                                         Ci.nsISupportsWeakReference]),
51
 
 
52
 
  observe: function BSS__observe(subject, topic, data) {
53
 
    switch (topic) {
54
 
    case "app-startup":
55
 
      let os = Cc["@mozilla.org/observer-service;1"].
56
 
               getService(Ci.nsIObserverService);
57
 
      os.addObserver(this, "final-ui-startup", true);
58
 
      break;
59
 
 
60
 
    case "final-ui-startup":
61
 
      // Force Weave service to load if it hasn't triggered from overlays
62
 
      this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
63
 
      this.timer.initWithCallback({
64
 
        notify: function() {
65
 
          Cu.import("resource://services-sync/main.js");
66
 
          if (Weave.Status.checkSetup() != Weave.CLIENT_NOT_CONFIGURED)
67
 
            Weave.Service;
68
 
        }
69
 
      }, 10000, Ci.nsITimer.TYPE_ONE_SHOT);
70
 
      break;
71
 
    }
72
 
  }
73
 
};
74
 
 
75
 
function AboutWeaveLog() {}
76
 
AboutWeaveLog.prototype = {
77
 
  classID: Components.ID("{d28f8a0b-95da-48f4-b712-caf37097be41}"),
78
 
 
79
 
  QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule,
80
 
                                         Ci.nsISupportsWeakReference]),
81
 
 
82
 
  getURIFlags: function(aURI) {
83
 
    return 0;
84
 
  },
85
 
 
86
 
  newChannel: function(aURI) {
87
 
    let dir = Cc["@mozilla.org/file/directory_service;1"].
88
 
      getService(Ci.nsIProperties);
89
 
    let file = dir.get("ProfD", Ci.nsILocalFile);
90
 
    file.append("weave");
91
 
    file.append("logs");
92
 
    file.append("verbose-log.txt");
93
 
    let ios = Cc["@mozilla.org/network/io-service;1"].
94
 
      getService(Ci.nsIIOService);
95
 
    let ch = ios.newChannel(ios.newFileURI(file).spec, null, null);
96
 
    ch.originalURI = aURI;
97
 
    return ch;
98
 
  }
99
 
};
100
 
 
101
 
function AboutWeaveLog1() {}
102
 
AboutWeaveLog1.prototype = {
103
 
  classID: Components.ID("{a08ee179-df50-48e0-9c87-79e4dd5caeb1}"),
104
 
 
105
 
  QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule,
106
 
                                         Ci.nsISupportsWeakReference]),
107
 
 
108
 
  getURIFlags: function(aURI) {
109
 
    return 0;
110
 
  },
111
 
 
112
 
  newChannel: function(aURI) {
113
 
    let dir = Cc["@mozilla.org/file/directory_service;1"].
114
 
      getService(Ci.nsIProperties);
115
 
    let file = dir.get("ProfD", Ci.nsILocalFile);
116
 
    file.append("weave");
117
 
    file.append("logs");
118
 
    file.append("verbose-log.txt.1");
119
 
    let ios = Cc["@mozilla.org/network/io-service;1"].
120
 
      getService(Ci.nsIIOService);
121
 
    let ch = ios.newChannel(ios.newFileURI(file).spec, null, null);
122
 
    ch.originalURI = aURI;
123
 
    return ch;
124
 
  }
125
 
};
126
 
 
127
 
let components = [WeaveService, AboutWeaveLog, AboutWeaveLog1];
128
 
 
129
 
// Gecko <2.0
130
 
function NSGetModule(compMgr, fileSpec) {
131
 
  return XPCOMUtils.generateModule(components);
132
 
}
133
 
 
134
 
// Gecko >=2.0
135
 
if (typeof XPCOMUtils.generateNSGetFactory == "function")
136
 
    const NSGetFactory = XPCOMUtils.generateNSGetFactory(components);