You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



Main Page   Compound List   File List   Compound Members  

tmTransactionService.h

00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is Mozilla Transaction Manager.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corp.
00018  * Portions created by the Initial Developer are Copyright (C) 2003
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   John Gaunt <jgaunt@netscape.com>
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef _tmTransactionService_H_
00039 #define _tmTransactionService_H_
00040 
00041 #include "ipcIService.h"
00042 #include "nsString.h"
00043 #include "nsVoidArray.h"
00044 #include "plhash.h"
00045 #include "tmITransactionService.h"
00046 #include "tmTransaction.h"
00047 #include "tmVector.h"
00048 
00049 // from tmTransactionManager.h
00050 //
00051 // XXX documentation needs work
00053 //  Overview of TransactionManager IPC Module
00054 //
00055 // Classes:
00056 //    tmIPCModule - From the tmTransactionManager's point of view, this
00057 //        is a proxy for the IPC daemon itself. The reverse is true
00058 //        from the daemon's point of view. This is an interface for the
00059 //        Transaction system to work with the IPC daemon as its transport
00060 //        layer.
00061 //    tmTransactionManager (TM) - Manages the different queues. Maintains
00062 //        the queues neccessary for different clients. Receives messages
00063 //        from the tmIPCModule and passes message to the IPC daemon through
00064 //        the tmIPCModule.
00065 //    tmQueue - this class manages the transactions for the different areas
00066 //        of the profiles being shared. Broken down by functional area there
00067 //        will be  a queue for prefs, cookies etc, but not for profileA and 
00068 //        profileB, and not for pref_delete, pref_create, pref_change etc...
00069 //    tmTransaction - the actual transaction being shared with the different
00070 //        tmClients. It contains the type of transaction, which will equate with
00071 //        a type of queue in existance, the owner of the transaction (an IPC daemon ID)
00072 //        and the actual text message to be shared. 
00073 //
00075 
00077 //
00078 // from tmqueue.cpp
00079 // Docs - note that the status of the TM_ATTACH_REPLY is only for checking
00080 //            for TM_ERROR_FAILURE. Other numbers have no importance
00081 // success of the status means the NS_ERROR_GET_CODE(status) will 
00082 //     yield the index of the listener.
00083 //
00084 // move to documentation page - from tmqueue.h
00085 //
00086 // a queue is specific to profile
00087 //
00088 // UUID going out from the module is a handler in the client 
00089 //          (will go to the XPCOM service impling that UUID)
00090 //   -- does it make sense to have different UUIDs for cookies/prefs/etc
00091 //
00092 
00093 
00094 struct queue_mapping;
00095 
00096 // This must match EXACTLY the ID in tmICPModule.h
00097 // UUID used to identify the Transaction Module in both daemon and client
00098 #define TRANSACTION_MODULE_ID                         \
00099 { /* c3dfbcd5-f51d-420b-abf4-3bae445b96a9 */          \
00100     0xc3dfbcd5,                                       \
00101     0xf51d,                                           \
00102     0x420b,                                           \
00103     {0xab, 0xf4, 0x3b, 0xae, 0x44, 0x5b, 0x96, 0xa9}  \
00104 }
00105 
00106 static const nsID kTransModuleID = TRANSACTION_MODULE_ID;
00107 
00108 
00118 class tmTransactionService : public tmITransactionService,
00119                              public ipcIMessageObserver
00120 {
00121 
00122 public:
00123 
00125   // Constructor & Destructor
00126 
00130   virtual ~tmTransactionService();
00131 
00132 
00133 
00135   // Interface Declarations
00136 
00137   NS_DECL_ISUPPORTS
00138 
00139   // ipcIMessageObserver
00140 
00151   NS_IMETHOD OnMessageAvailable(const nsID & aTarget, 
00152                                 const PRUint8 *aData, 
00153                                 PRUint32 aDataLength);
00154 
00155   // tmITransactionService
00156 
00166   NS_IMETHOD Init(const nsACString & aProfileName);
00167 
00179   NS_IMETHOD Attach(const nsACString & aQueueName, 
00180                     tmITransactionObserver *aObserver);
00181 
00194   NS_IMETHOD Detach(const nsACString & aQueueName);
00195 
00208   NS_IMETHOD Flush(const nsACString & aQueueName);
00209 
00222   NS_IMETHOD PostTransaction(const nsACString & aQueueName, 
00223                              const PRUint8 *aData, 
00224                              PRUint32 aDataLen);
00225 
00226 protected:
00227 
00229   // Protected Member Functions
00230 
00235   void SendMessage(tmTransaction *aTrans);
00236 
00237   // handlers for reply messages from TransactionManager
00238 
00247   nsresult OnAttachReply(tmTransaction *aTrans);
00248 
00255   nsresult OnDetachReply(tmTransaction *aTrans);
00256 
00262   nsresult OnFlushReply(tmTransaction *aTrans);
00263 
00269   nsresult OnPost(tmTransaction *aTrans);
00270 
00271   // other helper functions
00272 
00281   nsresult DispatchStoredMessages(queue_mapping *aQMapping);
00282 
00283   // helper methods for accessing the void arrays
00284 
00289   PRUint32 GetQueueID(const nsACString & aQueueName);
00290 
00296   char* GetJoinedQueueName(PRUint32 aQueueID);
00297 
00302   queue_mapping* GetQueueMap(PRUint32 aQueueID);
00303 
00305   // Protected Member Variables
00306 
00307   nsCString mProfileName;             // what profile are we dealing with
00308   PLHashTable *mObservers;            // maps qName -> tmITransactionObserver
00309 
00310   tmVector mQueueMaps;
00311   tmVector mWaitingMessages;
00312 
00313 private:
00314 
00315 };
00316 
00317 #endif

Generated on Mon Feb 24 10:22:50 2003 for transaction manager by doxygen1.3-rc3