diff --git a/widget/src/xremoteclient/Makefile.in b/widget/src/xremoteclient/Makefile.in index 55d74f99fc47..9da6eed7b642 100644 --- a/widget/src/xremoteclient/Makefile.in +++ b/widget/src/xremoteclient/Makefile.in @@ -35,23 +35,34 @@ REQUIRES = xpcom \ $(NULL) CPPSRCS = \ - XRemoteClient.cpp \ XRemoteClientFactory.cpp \ $(NULL) +ifdef MOZ_ENABLE_PHOTON + CPPSRCS += PhRemoteClient.cpp +else + CPPSRCS += XRemoteClient.cpp +endif + EXTRA_DSO_LDOPTS = \ $(XLIBS) $(XLDFLAGS) \ $(MOZ_COMPONENT_LIBS) \ $(NULL) +ifdef MOZ_ENABLE_PHOTON + EXTRA_DSO_LDOPTS += -lph +endif + EXPORTS = \ nsXRemoteClientCID.h +ifndef MOZ_ENABLE_PHOTON PROGRAM = mozilla-xremote-client$(BIN_SUFFIX) PROGOBJS = mozilla-xremote-client.$(OBJ_SUFFIX) \ XRemoteClient_standalone.$(OBJ_SUFFIX) \ $(NULL) +endif LIBS = \ $(NSPR_LIBS) \ @@ -63,5 +74,7 @@ ifeq ($(OS_ARCH), OpenVMS) DEFINES += -DGENERIC_MOTIF_REDEFINES endif +ifndef MOZ_ENABLE_PHOTON XRemoteClient_standalone.$(OBJ_SUFFIX): XRemoteClient.cpp $(CXX) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) -DXREMOTE_STANDALONE $< +endif diff --git a/widget/src/xremoteclient/PhRemoteClient.cpp b/widget/src/xremoteclient/PhRemoteClient.cpp new file mode 100644 index 000000000000..9682b7fb537b --- /dev/null +++ b/widget/src/xremoteclient/PhRemoteClient.cpp @@ -0,0 +1,105 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developers of the Original Code are Christopher + * Blizzard and Jamie Zawinski. Portions created Christopher Blizzard + * are Copyright (C) 2000 Christopher Blizzard. Portions created by + * Jamie Zawinski are Copyright (C) 1994 Netscape Communications + * Corporation. All Rights Reserved. + * + * Contributor(s): Adrian Mardare ( amardare@qnx.com ) + */ + +#include "PhRemoteClient.h" +#include "prmem.h" +#include "prprf.h" +#include "plstr.h" +#include "prsystem.h" +#include "prlog.h" +#include "prenv.h" +#include +#include +#include +#include +#include +#include +#include + +#define BrowserRemoteServerName "MozillaBrowserRemoteServer" +#define MailRemoteServerName "MozillaMailRemoteServer" +#define MOZ_REMOTE_MSG_TYPE 100 + +XRemoteClient::XRemoteClient() +{ + mInitialized = PR_FALSE; +} + +XRemoteClient::~XRemoteClient() +{ + if (mInitialized) + Shutdown(); +} + +NS_IMPL_ISUPPORTS1(XRemoteClient, nsIXRemoteClient) + +NS_IMETHODIMP +XRemoteClient::Init (void) +{ + + if (mInitialized) + return NS_OK; + + /* we have to initialize the toolkit since we use PtConnection stuff to send messages */ + PtInit( NULL ); + + mInitialized = PR_TRUE; + + return NS_OK; +} + +NS_IMETHODIMP +XRemoteClient::SendCommand (const char *aCommand, PRBool *aWindowFound) +{ + *aWindowFound = PR_TRUE; + + char *RemoteServerName; + + if( PL_strstr( aCommand, "mailto" ) ) + RemoteServerName = MailRemoteServerName; + else RemoteServerName = BrowserRemoteServerName; + + PtConnectionClient_t *cnt = PtConnectionFindName( RemoteServerName, 0, 0 ); + if( !cnt ) { + /* no window has registered for the remote service */ + *aWindowFound = PR_FALSE; + return NS_OK; + } + + if( PtConnectionSend( cnt, MOZ_REMOTE_MSG_TYPE, aCommand, NULL, strlen( aCommand ), 0 ) < 0 ) + return NS_ERROR_FAILURE; + + return NS_OK; +} + +NS_IMETHODIMP +XRemoteClient::Shutdown (void) +{ + + if (!mInitialized) + return NS_OK; + + // shut everything down + mInitialized = PR_FALSE; + + return NS_OK; +} diff --git a/widget/src/xremoteclient/PhRemoteClient.h b/widget/src/xremoteclient/PhRemoteClient.h new file mode 100644 index 000000000000..7481fc08c33e --- /dev/null +++ b/widget/src/xremoteclient/PhRemoteClient.h @@ -0,0 +1,38 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Christopher Blizzard. + * Portions created Christopher Blizzard are Copyright (C) Christopher + * Blizzard. All Rights Reserved. + * + * Contributor(s): Adrian Mardare ( amardare@qnx.com ) + */ + + +#include "nsIXRemoteClient.h" + +class XRemoteClient : public nsIXRemoteClient +{ + public: + XRemoteClient(); + virtual ~XRemoteClient(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIXRemoteClient + NS_DECL_NSIXREMOTECLIENT + + private: + PRBool mInitialized; +}; diff --git a/widget/src/xremoteclient/XRemoteClientFactory.cpp b/widget/src/xremoteclient/XRemoteClientFactory.cpp index 67571ebbc5f6..62162c28a31f 100644 --- a/widget/src/xremoteclient/XRemoteClientFactory.cpp +++ b/widget/src/xremoteclient/XRemoteClientFactory.cpp @@ -43,7 +43,12 @@ /* cfae5900-1dd1-11b2-95d0-ad454c233dc6 */ +#ifdef MOZ_WIDGET_PHOTON +#include "PhRemoteClient.h" +#else #include "XRemoteClient.h" +#endif + #include "nsXRemoteClientCID.h" #include "nsIGenericFactory.h"