Back to index

lightning-sunbird  0.9+nobinonly
nsGTKRemoteService.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* vim:expandtab:shiftwidth=2:tabstop=2:
00003  */
00004 /* ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is mozilla.org code.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Christopher Blizzard.
00021  * Portions created by the Initial Developer are Copyright (C) 2001
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   Christopher Blizzard <blizzard@mozilla.org>
00026  *   Benjamin Smedberg <benjamin@smedbergs.us>
00027  *
00028  * Alternatively, the contents of this file may be used under the terms of
00029  * either the GNU General Public License Version 2 or later (the "GPL"), or
00030  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00031  * in which case the provisions of the GPL or the LGPL are applicable instead
00032  * of those above. If you wish to allow use of your version of this file only
00033  * under the terms of either the GPL or the LGPL, and not to allow others to
00034  * use your version of this file under the terms of the MPL, indicate your
00035  * decision by deleting the provisions above and replace them with the notice
00036  * and other provisions required by the GPL or the LGPL. If you do not delete
00037  * the provisions above, a recipient may use your version of this file under
00038  * the terms of any one of the MPL, the GPL or the LGPL.
00039  *
00040  * ***** END LICENSE BLOCK ***** */
00041 
00042 #ifndef __nsGTKRemoteService_h__
00043 #define __nsGTKRemoteService_h__
00044 
00045 #include "nsIRemoteService.h"
00046 
00047 #include "nsIObserver.h"
00048 
00049 #include <gdk/gdk.h>
00050 #include <gdk/gdkx.h>
00051 #include <gtk/gtk.h>
00052 
00053 #include "nsString.h"
00054 #include "nsInterfaceHashtable.h"
00055 
00056 class nsIDOMWindow;
00057 class nsIWeakReference;
00058 class nsIWidget;
00059 
00060 class nsGTKRemoteService : public nsIRemoteService,
00061                            public nsIObserver
00062 {
00063 public:
00064   // We will be a static singleton, so don't use the ordinary methods.
00065   NS_DECL_ISUPPORTS
00066   NS_DECL_NSIREMOTESERVICE
00067   NS_DECL_NSIOBSERVER
00068 
00069   nsGTKRemoteService() :
00070     mServerWindow(NULL) { }
00071 
00072 private:
00073   ~nsGTKRemoteService() { }
00074 
00075   void HandleCommandsFor(GtkWidget* aWidget,
00076                          nsIWeakReference* aWindow);
00077 
00078   static void EnsureAtoms();
00079   static PLDHashOperator StartupHandler(const void* aKey,
00080                                         nsIWeakReference* aData,
00081                                         void* aClosure);
00082 
00083   static const char* HandleCommand(char* aCommand, nsIDOMWindow* aWindow);
00084 
00085 #ifdef MOZ_XUL_APP
00086   static const char* HandleCommandLine(char* aBuffer, nsIDOMWindow* aWindow);
00087 #endif
00088 
00089   static gboolean HandlePropertyChange(GtkWidget *widget,
00090                                        GdkEventProperty *event,
00091                                        nsIWeakReference* aThis);
00092 
00093   GtkWidget* mServerWindow;
00094   nsCString mAppName;
00095   nsCString mProfileName;
00096   nsInterfaceHashtable<nsVoidPtrHashKey, nsIWeakReference> mWindows;
00097 
00098   static Atom sMozVersionAtom;
00099   static Atom sMozLockAtom;
00100   static Atom sMozCommandAtom;
00101   static Atom sMozResponseAtom;
00102   static Atom sMozUserAtom;
00103   static Atom sMozProfileAtom;
00104   static Atom sMozProgramAtom;
00105   static Atom sMozCommandLineAtom;
00106 };
00107 
00108 #endif // __nsGTKRemoteService_h__