2008-04-20 00:20:57 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=2:tabstop=8:
|
|
|
|
*/
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-08-07 00:18:43 -07:00
|
|
|
#include <QWidget>
|
2008-04-20 00:20:57 -07:00
|
|
|
#include "nsQtRemoteService.h"
|
|
|
|
|
2010-07-02 06:51:58 -07:00
|
|
|
#include "mozilla/ModuleUtils.h"
|
2012-03-22 16:24:40 -07:00
|
|
|
#include "mozilla/X11Util.h"
|
2008-04-20 00:20:57 -07:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIAppShellService.h"
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2010-08-07 00:18:43 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
Helper class which is used to receive notification about property changes
|
|
|
|
*/
|
|
|
|
class MozQRemoteEventHandlerWidget: public QWidget {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor
|
|
|
|
@param aRemoteService remote service, which is notified about atom change
|
|
|
|
*/
|
|
|
|
MozQRemoteEventHandlerWidget(nsQtRemoteService &aRemoteService);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
Event filter, which receives all XEvents
|
|
|
|
@return false which continues event handling
|
|
|
|
*/
|
|
|
|
bool x11Event(XEvent *);
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
Service which is notified about property change
|
|
|
|
*/
|
|
|
|
nsQtRemoteService &mRemoteService;
|
|
|
|
};
|
|
|
|
|
|
|
|
MozQRemoteEventHandlerWidget::MozQRemoteEventHandlerWidget(nsQtRemoteService &aRemoteService)
|
|
|
|
:mRemoteService(aRemoteService)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MozQRemoteEventHandlerWidget::x11Event(XEvent *aEvt)
|
|
|
|
{
|
|
|
|
if (aEvt->type == PropertyNotify && aEvt->xproperty.state == PropertyNewValue)
|
|
|
|
mRemoteService.PropertyNotifyEvent(aEvt);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2008-04-20 00:20:57 -07:00
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS2(nsQtRemoteService,
|
|
|
|
nsIRemoteService,
|
|
|
|
nsIObserver)
|
|
|
|
|
2010-08-07 00:18:43 -07:00
|
|
|
nsQtRemoteService::nsQtRemoteService():
|
|
|
|
mServerWindow(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-04-20 00:20:57 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsQtRemoteService::Startup(const char* aAppName, const char* aProfileName)
|
|
|
|
{
|
2010-08-20 18:03:57 -07:00
|
|
|
#if (MOZ_PLATFORM_MAEMO == 5)
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#endif
|
2010-08-07 00:18:43 -07:00
|
|
|
if (mServerWindow) return NS_ERROR_ALREADY_INITIALIZED;
|
|
|
|
NS_ASSERTION(aAppName, "Don't pass a null appname!");
|
|
|
|
|
|
|
|
XRemoteBaseStartup(aAppName,aProfileName);
|
2008-04-20 00:20:57 -07:00
|
|
|
|
2010-08-07 00:18:43 -07:00
|
|
|
//Create window, which is not shown.
|
|
|
|
mServerWindow = new MozQRemoteEventHandlerWidget(*this);
|
|
|
|
|
|
|
|
HandleCommandsFor(mServerWindow->winId());
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2008-04-20 00:20:57 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsQtRemoteService::RegisterWindow(nsIDOMWindow* aWindow)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsQtRemoteService::Shutdown()
|
|
|
|
{
|
2010-08-07 00:18:43 -07:00
|
|
|
if (!mServerWindow)
|
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
|
|
|
|
|
|
|
delete mServerWindow;
|
2012-07-30 07:20:58 -07:00
|
|
|
mServerWindow = nullptr;
|
2010-08-07 00:18:43 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
2008-04-20 00:20:57 -07:00
|
|
|
}
|
|
|
|
|
2010-08-07 00:18:43 -07:00
|
|
|
void
|
|
|
|
nsQtRemoteService::PropertyNotifyEvent(XEvent *aEvt)
|
|
|
|
{
|
|
|
|
HandleNewProperty(aEvt->xproperty.window,
|
2012-03-22 16:24:40 -07:00
|
|
|
mozilla::DefaultXDisplay(),
|
2010-08-07 00:18:43 -07:00
|
|
|
aEvt->xproperty.time,
|
|
|
|
aEvt->xproperty.atom,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsQtRemoteService::SetDesktopStartupIDOrTimestamp(const nsACString& aDesktopStartupID,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aTimestamp)
|
2008-04-20 00:20:57 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// {C0773E90-5799-4eff-AD03-3EBCD85624AC}
|
|
|
|
#define NS_REMOTESERVICE_CID \
|
|
|
|
{ 0xc0773e90, 0x5799, 0x4eff, { 0xad, 0x3, 0x3e, 0xbc, 0xd8, 0x56, 0x24, 0xac } }
|
|
|
|
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsQtRemoteService)
|
2010-07-02 06:51:58 -07:00
|
|
|
NS_DEFINE_NAMED_CID(NS_REMOTESERVICE_CID);
|
2008-04-20 00:20:57 -07:00
|
|
|
|
2010-07-02 06:51:58 -07:00
|
|
|
static const mozilla::Module::CIDEntry kRemoteCIDs[] = {
|
|
|
|
{ &kNS_REMOTESERVICE_CID, false, NULL, nsQtRemoteServiceConstructor },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const mozilla::Module::ContractIDEntry kRemoteContracts[] = {
|
|
|
|
{ "@mozilla.org/toolkit/remote-service;1", &kNS_REMOTESERVICE_CID },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const mozilla::Module kRemoteModule = {
|
|
|
|
mozilla::Module::kVersion,
|
|
|
|
kRemoteCIDs,
|
|
|
|
kRemoteContracts
|
2008-04-20 00:20:57 -07:00
|
|
|
};
|
|
|
|
|
2010-07-02 06:51:58 -07:00
|
|
|
NSMODULE_DEFN(RemoteServiceModule) = &kRemoteModule;
|