gecko/toolkit/components/remote/nsQtRemoteService.cpp
Ehsan Akhgari 0fd9123eac Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00

141 lines
3.5 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=8:
*/
/* 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/. */
#include <QWidget>
#include "nsQtRemoteService.h"
#include "mozilla/ModuleUtils.h"
#include "mozilla/X11Util.h"
#include "nsIServiceManager.h"
#include "nsIAppShellService.h"
#include "nsCOMPtr.h"
/**
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;
}
NS_IMPL_ISUPPORTS2(nsQtRemoteService,
nsIRemoteService,
nsIObserver)
nsQtRemoteService::nsQtRemoteService():
mServerWindow(0)
{
}
NS_IMETHODIMP
nsQtRemoteService::Startup(const char* aAppName, const char* aProfileName)
{
#if (MOZ_PLATFORM_MAEMO == 5)
return NS_ERROR_NOT_IMPLEMENTED;
#endif
if (mServerWindow) return NS_ERROR_ALREADY_INITIALIZED;
NS_ASSERTION(aAppName, "Don't pass a null appname!");
XRemoteBaseStartup(aAppName,aProfileName);
//Create window, which is not shown.
mServerWindow = new MozQRemoteEventHandlerWidget(*this);
HandleCommandsFor(mServerWindow->winId());
return NS_OK;
}
NS_IMETHODIMP
nsQtRemoteService::RegisterWindow(nsIDOMWindow* aWindow)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsQtRemoteService::Shutdown()
{
if (!mServerWindow)
return NS_ERROR_NOT_INITIALIZED;
delete mServerWindow;
mServerWindow = nullptr;
return NS_OK;
}
void
nsQtRemoteService::PropertyNotifyEvent(XEvent *aEvt)
{
HandleNewProperty(aEvt->xproperty.window,
mozilla::DefaultXDisplay(),
aEvt->xproperty.time,
aEvt->xproperty.atom,
0);
}
void
nsQtRemoteService::SetDesktopStartupIDOrTimestamp(const nsACString& aDesktopStartupID,
uint32_t aTimestamp)
{
}
// {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)
NS_DEFINE_NAMED_CID(NS_REMOTESERVICE_CID);
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
};
NSMODULE_DEFN(RemoteServiceModule) = &kRemoteModule;