1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/* synctime.c
*
* Copyright (C) 1999 by Judd Montgomery
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <pi-dlp.h>
#include <pi-source.h>
#include "libplugin.h"
void plugin_version(int *major_version, int *minor_version)
{
*major_version=0;
*minor_version=99;
}
int plugin_get_name(char *name, int len)
{
strncpy(name, "SyncTime 0.99", len);
return 0;
}
int plugin_get_help_name(char *name, int len)
{
strncpy(name, "About SyncTime", len);
return 0;
}
int plugin_help(char **text, int *width, int *height)
{
/* We could also pass back *text=NULL */
*text = strdup(
/*-------------------------------------------*/
"SyncTime plugin for J-Pilot was written by\n"
"Judd Montgomery (c) 1999.\n"
"judd@jpilot.org\n"
"http://jpilot.org\n"
"SyncTime WILL NOT work with PalmOS 3.3!\n"
);
*height = 200;
*width = 300;
return 0;
}
int plugin_sync(int sd)
{
int r;
time_t ltime;
unsigned long ROMversion, majorVersion, minorVersion;
jp_init();
dlp_ReadFeature(sd, makelong("psys"), 1, &ROMversion);
majorVersion = (((ROMversion >> 28) & 0xf) * 10)+ ((ROMversion >> 24) & 0xf);
minorVersion = (((ROMversion >> 20) & 0xf) * 10)+ ((ROMversion >> 16) & 0xf);
jp_logf(LOG_GUI, "synctime: Palm OS version %d.%d\n", majorVersion, minorVersion);
if ((majorVersion==3) && (minorVersion==30)) {
jp_logf(LOG_GUI, "synctime: Palm OS Version 3.30 does not support SyncTime\n");
jp_logf(LOG_GUI, "synctime: NOT setting the time on the pilot\n");
return 1;
}
jp_logf(LOG_GUI, "synctime: setting the time on the pilot\n");
time(<ime);
r = dlp_SetSysDateTime(sd, ltime);
return 0;
}
|