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 Mozilla Transaction Manager.
|
---|
15 | *
|
---|
16 | * The Initial Developer of the Original Code is
|
---|
17 | * Netscape Communications Corp.
|
---|
18 | * Portions created by the Initial Developer are Copyright (C) 2003
|
---|
19 | * the Initial Developer. All Rights Reserved.
|
---|
20 | *
|
---|
21 | * Contributor(s):
|
---|
22 | * John Gaunt <jgaunt@netscape.com>
|
---|
23 | *
|
---|
24 | * Alternatively, the contents of this file may be used under the terms of
|
---|
25 | * either the GNU General Public License Version 2 or later (the "GPL"), or
|
---|
26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
28 | * of those above. If you wish to allow use of your version of this file only
|
---|
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
30 | * use your version of this file under the terms of the MPL, indicate your
|
---|
31 | * decision by deleting the provisions above and replace them with the notice
|
---|
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
33 | * the provisions above, a recipient may use your version of this file under
|
---|
34 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
35 | *
|
---|
36 | * ***** END LICENSE BLOCK ***** */
|
---|
37 |
|
---|
38 | // from tmTransactionManager.h
|
---|
39 | //
|
---|
40 | // XXX documentation needs work
|
---|
41 | //////////////////////////////////////////////////////////////////////////////
|
---|
42 | // Overview of TransactionManager IPC Module
|
---|
43 | //
|
---|
44 | // Classes:
|
---|
45 | // tmIPCModule - From the tmTransactionManager's point of view, this
|
---|
46 | // is a proxy for the IPC daemon itself. The reverse is true
|
---|
47 | // from the daemon's point of view. This is an interface for the
|
---|
48 | // Transaction system to work with the IPC daemon as its transport
|
---|
49 | // layer.
|
---|
50 | // tmTransactionManager (TM) - Manages the different queues. Maintains
|
---|
51 | // the queues neccessary for different clients. Receives messages
|
---|
52 | // from the tmIPCModule and passes message to the IPC daemon through
|
---|
53 | // the tmIPCModule.
|
---|
54 | // tmQueue - this class manages the transactions for the different areas
|
---|
55 | // of the profiles being shared. Broken down by functional area there
|
---|
56 | // will be a queue for prefs, cookies etc, but not for profileA and
|
---|
57 | // profileB, and not for pref_delete, pref_create, pref_change etc...
|
---|
58 | // tmTransaction - the actual transaction being shared with the different
|
---|
59 | // tmClients. It contains the type of transaction, which will equate with
|
---|
60 | // a type of queue in existance, the owner of the transaction (an IPC daemon ID)
|
---|
61 | // and the actual text message to be shared.
|
---|
62 | //
|
---|
63 | //////////////////////////////////////////////////////////////////////////////
|
---|
64 |
|
---|
65 | /// XXX some docs that need to be put somewhere:
|
---|
66 | //
|
---|
67 | // from tmqueue.cpp
|
---|
68 | // Docs - note that the status of the TM_ATTACH_REPLY is only for checking
|
---|
69 | // for TM_ERROR_FAILURE. Other numbers have no importance
|
---|
70 | // success of the status means the NS_ERROR_GET_CODE(status) will
|
---|
71 | // yield the index of the listener.
|
---|
72 | //
|
---|
73 | // move to documentation page - from tmqueue.h
|
---|
74 | //
|
---|
75 | // a queue is specific to profile
|
---|
76 | //
|
---|
77 | // UUID going out from the module is a handler in the client
|
---|
78 | // (will go to the XPCOM service impling that UUID)
|
---|
79 | // -- does it make sense to have different UUIDs for cookies/prefs/etc
|
---|
80 | //
|
---|
81 |
|
---|
82 | #include "nsISupports.idl"
|
---|
83 |
|
---|
84 | interface ipcITransactionObserver;
|
---|
85 |
|
---|
86 | [scriptable, uuid(15561efb-8c58-4a47-813a-fa91cf730895)]
|
---|
87 | interface ipcITransactionService : nsISupports
|
---|
88 | {
|
---|
89 | /**
|
---|
90 | * Connects the application to the transaction manager, defines the
|
---|
91 | * namespace and initializes internal storage
|
---|
92 | *
|
---|
93 | * @param aNamespace
|
---|
94 | * A string defining the scope of the transaction domains. It is
|
---|
95 | * used internally to seperate process listening to the same domain
|
---|
96 | * (ie. preferences) but for two different namespaces (ie. profile1 vs
|
---|
97 | * profile2).
|
---|
98 | *
|
---|
99 | * @returns NS_OK if all memory allocated properly and the IPC service was
|
---|
100 | * reached and attached to successfully.
|
---|
101 | *
|
---|
102 | * @returns an NS_ERROR_<foo> code specific to the failure otherwise
|
---|
103 | */
|
---|
104 | void init(in ACString aNamespace);
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Links the observer passed in with the domain specified. This will allow
|
---|
108 | * the observer to post transactions dealing with this domain as well as
|
---|
109 | * receive transactions posted by other applications observing this
|
---|
110 | * domain.
|
---|
111 | *
|
---|
112 | * Return codes for this method confer information about the success of
|
---|
113 | * this call, not of the actual attaching of the observer to the domain.
|
---|
114 | * (except the TM_ERROR code - which means the observer can not attach)
|
---|
115 | * If the attach is successful the observer will have its OnAttachReply
|
---|
116 | * method called before this method returns.
|
---|
117 | *
|
---|
118 | * Note: This call is synchronous and will not return until the call to
|
---|
119 | * OnAttachReply is made.
|
---|
120 | *
|
---|
121 | * @param aDomainName
|
---|
122 | * the name of the domain, in the current namespace, to listen for
|
---|
123 | * transactions from. i.e. cookies
|
---|
124 | *
|
---|
125 | * @param aObserver
|
---|
126 | * this will be used to notify the application when transactions
|
---|
127 | * and messages come in.
|
---|
128 | *
|
---|
129 | * @param aLockingCall
|
---|
130 | * Have the Transaction Sevice acquire a lock based on the domain
|
---|
131 | * before attaching. This should be used when persistant storage
|
---|
132 | * is being used to prevent data corruption.
|
---|
133 | *
|
---|
134 | * @returns NS_OK if the attach message was sent to the Transaction Manager.
|
---|
135 | *
|
---|
136 | * @returns an NS_ERROR_<foo> code specific to the failure otherwise
|
---|
137 | *
|
---|
138 | * @returns TM_ERROR_QUEUE_EXISTS if the queue already exists which means
|
---|
139 | * someone has already attached to it.
|
---|
140 | */
|
---|
141 | void attach(in ACString aDomainName,
|
---|
142 | in ipcITransactionObserver aObserver,
|
---|
143 | in PRBool aLockingCall);
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * Sends a detach message to the Transaction Manager to unlink the observer
|
---|
147 | * associated with the domain passed in.
|
---|
148 | *
|
---|
149 | * As in attach, return codes do not indicate success of detachment. The
|
---|
150 | * observer will have it's OnDetach method called if it is successfully
|
---|
151 | * detached.
|
---|
152 | *
|
---|
153 | * Note: This call is an asynchronous call.
|
---|
154 | *
|
---|
155 | * @param aDomainName
|
---|
156 | * the domain, in the current namespace, from which the client
|
---|
157 | * should be removed.
|
---|
158 | *
|
---|
159 | * @returns NS_OK if the detach message is sent to the Transaction Manager
|
---|
160 | *
|
---|
161 | * @returns NS_ERROR_FAILURE is something goes wrong
|
---|
162 | *
|
---|
163 | * @returns NS_ERRROR_UNEXPECTD if the domain does not have an observer
|
---|
164 | * attached
|
---|
165 | */
|
---|
166 | void detach(in ACString aDomainName);
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * Sends a flush message to the Transaction Manager to remove all
|
---|
170 | * transactions for the domain. After this call there will be no
|
---|
171 | * transactions in the Transaction Manager for the namespace/domain
|
---|
172 | * pairing. It is up to the application to coordinate the flushing
|
---|
173 | * of the Transaction Manager with the writing of data to files,
|
---|
174 | * if needed.
|
---|
175 | *
|
---|
176 | * Note: This call is synchronous and will not return until the call to
|
---|
177 | * OnFlushReply is made.
|
---|
178 | *
|
---|
179 | * @param aDomainName
|
---|
180 | * The domain, in the current namespace, to flush.
|
---|
181 | *
|
---|
182 | * @param aLockingCall
|
---|
183 | * Have the Transaction Sevice acquire a lock based on the domain
|
---|
184 | * before flushing. This should be used when persistant storage
|
---|
185 | * is being used to prevent data corruption.
|
---|
186 | *
|
---|
187 | * @returns NS_OK if the flush message is sent to the Transaction Manager
|
---|
188 | *
|
---|
189 | * @returns NS_ERROR_FAILURE is something goes wrong
|
---|
190 | *
|
---|
191 | * @returns NS_ERRROR_UNEXPECTD if the domain does not have an observer
|
---|
192 | * attached
|
---|
193 | */
|
---|
194 | void flush(in ACString aDomainName, in PRBool aLockingCall);
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * Send the data to the Transaction Manager to be broadcast to any
|
---|
198 | * applications that have registered as observers of this particular
|
---|
199 | * namespace/domain pairing.
|
---|
200 | *
|
---|
201 | * If this domain is not being observed (attach has not been called for
|
---|
202 | * this domain) the message is queued until the attach is made and then
|
---|
203 | * the message is sent to the Transaction Manager with the proper domain
|
---|
204 | * information.
|
---|
205 | *
|
---|
206 | * XXXjg - this may not be neccessary with the synch attach call.
|
---|
207 | *
|
---|
208 | * Note: This call is an asynchronous call.
|
---|
209 | *
|
---|
210 | * @param aDomainName
|
---|
211 | * the domain, in the current namespace, to which the data will be
|
---|
212 | * sent.
|
---|
213 | *
|
---|
214 | * @param aData
|
---|
215 | * The actual data to be sent.
|
---|
216 | *
|
---|
217 | * @param aDataLen
|
---|
218 | * The length of the data argument
|
---|
219 | */
|
---|
220 | void postTransaction(in ACString aDomainName,
|
---|
221 | [array, const, size_is(aDataLen)]
|
---|
222 | in octet aData,
|
---|
223 | in unsigned long aDataLen);
|
---|
224 | };
|
---|
225 |
|
---|
226 | %{C++
|
---|
227 | // singleton implementing ipcITransactionService
|
---|
228 | #define IPC_TRANSACTIONSERVICE_CLASSNAME \
|
---|
229 | "tmTransactionService"
|
---|
230 | #define IPC_TRANSACTIONSERVICE_CONTRACTID \
|
---|
231 | "@mozilla.org/ipc/transaction-service;1"
|
---|
232 | #define IPC_TRANSACTIONSERVICE_CID \
|
---|
233 | { /* 1403adf4-94d1-4c67-a8ae-d9f86972d378 */ \
|
---|
234 | 0x1403adf4, \
|
---|
235 | 0x94d1, \
|
---|
236 | 0x4c67, \
|
---|
237 | {0xa8, 0xae, 0xd9, 0xf8, 0x69, 0x72, 0xd3, 0x78} \
|
---|
238 | }
|
---|
239 | %}
|
---|