1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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
14
* The Original Code is Mozilla IPC.
16
* The Initial Developer of the Original Code is
17
* Netscape Communications Corporation.
18
* Portions created by the Initial Developer are Copyright (C) 2002
19
* the Initial Developer. All Rights Reserved.
22
* Darin Fisher <darin@netscape.com>
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.
36
* ***** END LICENSE BLOCK ***** */
38
#ifndef ipcClientUnix_h__
39
#define ipcClientUnix_h__
42
#include "ipcMessageQ.h"
43
#include "ipcStringList.h"
44
#include "ipcIDList.h"
50
//-----------------------------------------------------------------------------
53
// NOTE: this class is an implementation detail of the IPC daemon. IPC daemon
54
// modules (other than the built-in IPCM module) must not access methods on
55
// this class directly. use the API provided via ipcd.h instead.
56
//-----------------------------------------------------------------------------
64
PRUint32 ID() const { return mID; }
66
void AddName(const char *name);
67
void DelName(const char *name);
68
PRBool HasName(const char *name) const { return mNames.Find(name) != NULL; }
70
void AddTarget(const nsID &target);
71
void DelTarget(const nsID &target);
72
PRBool HasTarget(const nsID &target) const { return mTargets.Find(target) != NULL; }
75
const ipcStringNode *Names() const { return mNames.First(); }
76
const ipcIDNode *Targets() const { return mTargets.First(); }
78
// returns primary client name (the one specified in the "client hello" message)
79
const char *PrimaryName() const { return mNames.First() ? mNames.First()->Value() : NULL; }
81
void SetExpectsSyncReply(PRBool val) { mExpectsSyncReply = val; }
82
PRBool GetExpectsSyncReply() const { return mExpectsSyncReply; }
85
PRUint32 PID() const { return mPID; }
86
void SetPID(PRUint32 pid) { mPID = pid; }
88
HWND Hwnd() const { return mHwnd; }
89
void SetHwnd(HWND hwnd) { mHwnd = hwnd; }
92
#if defined(XP_UNIX) || defined(XP_OS2)
94
// called to process a client file descriptor. the value of pollFlags
95
// indicates the state of the socket.
98
// 0 - to cancel client connection
99
// PR_POLL_READ - to poll for a readable socket
100
// PR_POLL_WRITE - to poll for a writable socket
101
// (both flags) - to poll for either a readable or writable socket
103
// the socket is non-blocking.
105
int Process(PRFileDesc *sockFD, int pollFlags);
108
// on success or failure, this function takes ownership of |msg| and will
109
// delete it when appropriate.
111
void EnqueueOutboundMsg(ipcMessage *msg) { mOutMsgQ.Append(msg); }
115
static PRUint32 gLastID;
118
ipcStringList mNames;
120
PRBool mExpectsSyncReply;
123
// on windows, we store the PID of the client process to help us determine
124
// the client from which a message originated. each message has the PID
128
// the hwnd of the client's message window.
132
#if defined(XP_UNIX) || defined(XP_OS2)
133
ipcMessage mInMsg; // buffer for incoming message
134
ipcMessageQ mOutMsgQ; // outgoing message queue
136
// keep track of the amount of the first message sent
137
PRUint32 mSendOffset;
139
// utility function for writing out messages.
140
int WriteMsgs(PRFileDesc *fd);
144
#endif // !ipcClientUnix_h__