Add define WINDOWS_SYS for windows compile in RetroShare.pro.

Now the idle functions for windows are used.
Removed unused file idle_mac.cpp.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3463 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-09 11:09:40 +00:00
parent 87d2cec44c
commit 7c126f24ba
2 changed files with 3 additions and 161 deletions

View File

@ -76,7 +76,7 @@ win32-x-g++ {
LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32 -gdi32
LIBS += -lole32 -lwinmm
DEFINES *= WIN32 WIN32_CROSS_UBUNTU
DEFINES *= WINDOWS_SYS WIN32 WIN32_CROSS_UBUNTU
INCLUDEPATH += ../../../../gpgme-1.1.8/src/
INCLUDEPATH += ../../../../libgpg-error-1.7/src/
@ -101,6 +101,8 @@ win32 {
LIBS += -lole32 -lwinmm
RC_FILE = gui/images/retroshare_win.rc
DEFINES += WINDOWS_SYS
GPG_ERROR_DIR = ../../../../libgpg-error-1.7
GPGME_DIR = ../../../../gpgme-1.1.8
INCLUDEPATH += . $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src

View File

@ -1,160 +0,0 @@
/*
* idle_mac.cpp - detect desktop idle time
* Copyright (C) 2003 Tarkvara Design Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "idle.h"
#include <Carbon/Carbon.h>
// Why does Apple have to make this so complicated?
static OSStatus LoadFrameworkBundle(CFStringRef framework, CFBundleRef *bundlePtr) {
OSStatus err;
FSRef frameworksFolderRef;
CFURLRef baseURL;
CFURLRef bundleURL;
if ( bundlePtr == nil ) return( -1 );
*bundlePtr = nil;
baseURL = nil;
bundleURL = nil;
err = FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, true, &frameworksFolderRef);
if (err == noErr) {
baseURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &frameworksFolderRef);
if (baseURL == nil) {
err = coreFoundationUnknownErr;
}
}
if (err == noErr) {
bundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL, framework, false);
if (bundleURL == nil) {
err = coreFoundationUnknownErr;
}
}
if (err == noErr) {
*bundlePtr = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
if (*bundlePtr == nil) {
err = coreFoundationUnknownErr;
}
}
if (err == noErr) {
if ( ! CFBundleLoadExecutable( *bundlePtr ) ) {
err = coreFoundationUnknownErr;
}
}
// Clean up.
if (err != noErr && *bundlePtr != nil) {
CFRelease(*bundlePtr);
*bundlePtr = nil;
}
if (bundleURL != nil) {
CFRelease(bundleURL);
}
if (baseURL != nil) {
CFRelease(baseURL);
}
return err;
}
class IdlePlatform::Private {
public:
EventLoopTimerRef mTimerRef;
int mSecondsIdle;
Private() : mTimerRef(0), mSecondsIdle(0) {}
static pascal void IdleTimerAction(EventLoopTimerRef, EventLoopIdleTimerMessage inState, void* inUserData);
};
pascal void IdlePlatform::Private::IdleTimerAction(EventLoopTimerRef, EventLoopIdleTimerMessage inState, void* inUserData) {
switch (inState) {
case kEventLoopIdleTimerStarted:
case kEventLoopIdleTimerStopped:
// Get invoked with this constant at the start of the idle period,
// or whenever user activity cancels the idle.
((IdlePlatform::Private*)inUserData)->mSecondsIdle = 0;
break;
case kEventLoopIdleTimerIdling:
// Called every time the timer fires (i.e. every second).
((IdlePlatform::Private*)inUserData)->mSecondsIdle++;
break;
}
}
IdlePlatform::IdlePlatform() {
d = new Private();
}
IdlePlatform::~IdlePlatform() {
RemoveEventLoopTimer(d->mTimerRef);
delete d;
}
// Typedef for the function we're getting back from CFBundleGetFunctionPointerForName.
typedef OSStatus (*InstallEventLoopIdleTimerPtr)(EventLoopRef inEventLoop,
EventTimerInterval inFireDelay,
EventTimerInterval inInterval,
EventLoopIdleTimerUPP inTimerProc,
void * inTimerData,
EventLoopTimerRef * outTimer);
bool IdlePlatform::init() {
// May already be init'ed.
if (d->mTimerRef) {
return true;
}
// According to the docs, InstallEventLoopIdleTimer is new in 10.2.
// According to the headers, it has been around since 10.0.
// One of them is lying. We'll play it safe and weak-link the function.
// Load the "Carbon.framework" bundle.
CFBundleRef carbonBundle;
if (LoadFrameworkBundle( CFSTR("Carbon.framework"), &carbonBundle ) != noErr) {
return false;
}
// Load the Mach-O function pointers for the routine we will be using.
InstallEventLoopIdleTimerPtr myInstallEventLoopIdleTimer = (InstallEventLoopIdleTimerPtr)CFBundleGetFunctionPointerForName(carbonBundle, CFSTR("InstallEventLoopIdleTimer"));
if (myInstallEventLoopIdleTimer == 0) {
return false;
}
EventLoopIdleTimerUPP timerUPP = NewEventLoopIdleTimerUPP(Private::IdleTimerAction);
if ((*myInstallEventLoopIdleTimer)(GetMainEventLoop(), kEventDurationSecond, kEventDurationSecond, timerUPP, 0, &d->mTimerRef)) {
return true;
}
return false;
}
int IdlePlatform::secondsIdle() {
return d->mSecondsIdle;
}