aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/my/idle_mac.cpp
diff options
context:
space:
mode:
authorGravatar Robert Förster2009-09-01 22:12:36 +0000
committerGravatar Robert Förster2009-09-01 22:12:36 +0000
commitea06d9bbbd8d8ef75034bfc3f62838f193537984 (patch)
treea437eeabaa4b3d09f3313a6b0dd07b5bb961749d /src/modules/my/idle_mac.cpp
parentupdated splash screen (diff)
downloadKVIrc-ea06d9bbbd8d8ef75034bfc3f62838f193537984.tar.gz
KVIrc-ea06d9bbbd8d8ef75034bfc3f62838f193537984.tar.bz2
KVIrc-ea06d9bbbd8d8ef75034bfc3f62838f193537984.zip
- trailing whitespace cleanups all over the place
- removed charset dependent manpages since it really makes no sense to distribute them, they are getting installed in non standard places and one manpage per language is enough - added SpotChat to the serverdb, happens to be my network anyway :P (someone should remind me to check all the networks and servers there so we can do a cleanup if needed git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3463 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/my/idle_mac.cpp')
-rw-r--r--src/modules/my/idle_mac.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/modules/my/idle_mac.cpp b/src/modules/my/idle_mac.cpp
index a111a7cbd..520f5f420 100644
--- a/src/modules/my/idle_mac.cpp
+++ b/src/modules/my/idle_mac.cpp
@@ -22,21 +22,21 @@
#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);
@@ -61,7 +61,7 @@
err = coreFoundationUnknownErr;
}
}
-
+
// Clean up.
if (err != noErr && *bundlePtr != nil) {
CFRelease(*bundlePtr);
@@ -69,27 +69,27 @@
}
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:
@@ -104,18 +104,18 @@
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,
@@ -123,39 +123,39 @@
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;
}