home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
linuxmafia.com 2016
/
linuxmafia.com.tar
/
linuxmafia.com
/
pub
/
palmos
/
linkmaster-src-1.0.4.tar.gz
/
linkmaster-src-1.0.4.tar
/
linkmaster-1.0.4
/
hack
/
code03e9.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-05
|
3KB
|
121 lines
/* code03e9.c - SysUIAppSwitch handler
Copyright ⌐ 1999 Ben Darnell
This file is a part of LinkMaster,
which is distributed under the GNU GPL.
Based on SampleHack by Roger Chaplin <foursquaredev@att.net>
*/
#include <Pilot.h>
#include <FeatureMgr.h>
#include "linkhistoryhack.h"
#include "linkhistoryhackRsc.h"
#define NO_LINKHISTORY
#define NO_LINKSIMPLE
#define NO_LINKCONTAINER
#include "linkaware.h"
/* copied from linkmaster/proxy/al/proxyapp.c */
typedef struct {
DWord creator;
DWord app_creator;
} LaunchLinkInfoType;
typedef LaunchLinkInfoType* LaunchLinkInfoPtr;
static LaunchLinkInfoPtr LaunchLinkNew(DWord creator, CharPtr title);
static void LinkHistoryPush(LinkInfoPtr linkinfo);
Err SysUIAppSwitchHandler(UInt cardno, LocalID dbid, Word cmd, Ptr cmdPBP)
{
DWord temp;
Err (*oldTrap)(UInt,LocalID,Word,Ptr);
ULong creator, type;
Char name[33];
MyPrefsType prefs;
Word prefssize=sizeof(prefs);
SWord prefsver;
FtrGet(MYCRID, 0x3e9, &temp);
oldTrap=(Err(*)(UInt,LocalID,Word,Ptr))temp;
/* check prefs */
prefsver=PrefGetAppPreferences('LMHH', 0, &prefs, &prefssize, true);
if (prefsver<1)
prefs.trackapps=1;
if (prefs.trackapps) {
/* get creator id of app being launched */
DmDatabaseInfo(cardno, dbid, name,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL, &type, &creator);
/* ignore prefs panels */
if (type!='panl') {
/* publish the link */
LinkHistoryPush((LinkInfoPtr)LaunchLinkNew(creator, name));
}
}
return oldTrap(cardno, dbid, cmd, cmdPBP);
}
/* this function taken from linkmaster/proxy/al/proxyapp.c */
static LaunchLinkInfoPtr LaunchLinkNew(DWord creator, CharPtr title)
{
LaunchLinkInfoPtr linkinfo;
if (title) {
/* title is truncated to 32 chars or at the first \n */
int titlelen=32;
int tmp;
tmp=StrLen(title);
if (tmp<titlelen) titlelen=tmp;
tmp=StrChr(title, '\n')-title;
if ((tmp>0)&&(tmp<titlelen)) titlelen=tmp;
linkinfo=MemPtrNew(65+titlelen);
if (!linkinfo) return NULL;
MemSet(linkinfo, 65+titlelen, 0);
StrNCopy(((CharPtr)linkinfo)+64, title, titlelen);
((CharPtr)linkinfo)[64+titlelen]=0;
} else {
linkinfo=MemPtrNew(64);
MemSet(linkinfo, 64, 0);
};
linkinfo->creator='LPal';
linkinfo->app_creator=creator;
return linkinfo;
}
/* copied from linkmaster/linkaware.c */
void LinkHistoryPush(LinkInfoPtr linkinfo)
{
Err err;
DmSearchStateType searchstate;
UInt cardno;
LocalID dbid;
DWord result;
if (!linkinfo)
return;
/*if (!LinkCheck()) {
MemPtrFree(linkinfo);
return;
}*/
err=DmGetNextDatabaseByTypeCreator(true, &searchstate, 'appl', 'Link', true,
&cardno, &dbid);
if (err) {
MemPtrFree(linkinfo);
return;
};
MemPtrSetOwner(linkinfo, 0);
SysAppLaunch(cardno, dbid, 0, linkAppLaunchHistoryPush,
(Ptr)linkinfo, &result);
}