File pilot-mailsync-0.9.1-pilot-link-0.12.patch of Package pilot-mailsync
--- palmmail.c
+++ palmmail.c
@@ -51,7 +51,7 @@
void PalmToMail(const char *from)
{
unsigned char buffer[0xffff]; /* XXX could probably be (a lot) smaller */
- int len, size, attr, sendmail_ret;
+ int len, attr, sendmail_ret;
recordid_t id;
int clear_replyto_pointer_later;
nFromPalm = 0;
@@ -61,7 +61,7 @@
* anywhere?
*/
while (0 <= (len = dlp_ReadNextRecInCategory(gSocket, gDB, mailCtgOutbox,
- buffer, &id, 0, &size,
+ buffer, &id, 0,
&attr))) {
struct Mail mail;
struct VersaMail versamail;
@@ -197,7 +197,7 @@
int
DeleteMails(MAILSTREAM *mailStream)
{
- int len, size, attr, deleteFlag = 0;
+ int len, attr, deleteFlag = 0;
int msgno;
char buffer[0xffff];
recordid_t id;
@@ -206,7 +206,7 @@
/* delete emails in the "Deleted" category on the Pilot */
dlp_ResetDBIndex(gSocket, gDB);
while (0 <= (len = dlp_ReadNextRecInCategory(gSocket, gDB, mailCtgDeleted,
- buffer, &id, 0, &size, &attr))) {
+ buffer, &id, 0, &attr))) {
/* delete if we do SyncAll
* or if gDelete and not Hotsync-unread since
* the Hotsync-Unread Options says something of keeping
@@ -240,7 +240,7 @@
if (gDeleteRead) {
dlp_ResetDBIndex(gSocket, gDB);
while (0 <= (len = dlp_ReadNextRecInCategory(gSocket, gDB, mailCtgInbox,
- buffer, &id, 0, &size, &attr))) {
+ buffer, &id, 0, &attr))) {
struct Mail mail;
unpack_Mail(&mail, buffer, len);
@@ -265,7 +265,7 @@
void
UpdateSeenFlags(MailCategory mailCtg, MAILSTREAM *mailStream)
{
- int len, size, attr;
+ int len, attr;
int msgno;
char buffer[0xffff];
recordid_t id;
@@ -274,7 +274,7 @@
/* consider every message in the Inbox */
dlp_ResetDBIndex(gSocket,gDB);
while (0 <= (len = dlp_ReadNextRecInCategory(gSocket, gDB, mailCtg,
- buffer, &id, 0, &size, &attr))) {
+ buffer, &id, 0, &attr))) {
struct Mail mail;
int multi=0; /* guard against one-to-many matches */
@@ -320,7 +320,7 @@
void
SynchronizeFlags(MailCategory mailCtg, MAILSTREAM *mailStream)
{
- int len, size, attr;
+ int len, attr;
int msgno;
char buffer[0xffff];
@@ -336,7 +336,7 @@
/* consider every message in the Inbox */
dlp_ResetDBIndex(gSocket,gDB);
while (0 <= (len = dlp_ReadNextRecInCategory(gSocket, gDB, mailCtg,
- buffer, &id, 0, &size, &attr))) {
+ buffer, &id, 0, &attr))) {
struct Mail mail;
struct VersaMail versaMail;
int multi=0; /* guard against one-to-many matches */
--- pilot-mailsync.c
+++ pilot-mailsync.c
@@ -34,6 +34,7 @@
#include <arpa/inet.h>
#include <netdb.h>
+#include <pi-version.h>
#include <pi-source.h>
#include <pi-socket.h>
#include <time.h> /* XXX pilot-link bug: required before pi-mail.h */
@@ -76,7 +77,12 @@
{
struct PilotUser pi_user;
int bufsize = 0xffff; /* XXX could probably be smaller */
+#if defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0)
+ pi_buffer_t *pi_buf = pi_buffer_new(bufsize);
+#else
unsigned char buffer[bufsize];
+#endif /* defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0) */
+
int version;
int size;
@@ -100,10 +106,16 @@
}
len = dlp_ReadAppPreference(gSocket, makelong("asc3"), (gVersaMail-1)*19+16, 1,
+#if defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0)
+ bufsize, pi_buf->data, &size, &version);
+ if ( (len > 2) && (strcmp(pi_buf->data,"@@deleted")))
+ printf("Using VersaMail-Account %d: %s\n",gVersaMail,pi_buf->data);
+#else
bufsize, buffer, &size, &version);
-
if ( (len > 2) && (strcmp(buffer,"@@deleted")))
printf("Using VersaMail-Account %d: %s\n",gVersaMail,buffer);
+#endif /* defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0) */
+
else{
printf("VersaMail-Account %d does not exist or is deleted\n",gVersaMail);
CloseMailDB();
@@ -123,13 +135,21 @@
CloseMailDB();
exit(1);
}
-
+#if defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0)
+ dlp_ReadAppBlock(gSocket, gDB, 0, -1, pi_buf);
+#else
dlp_ReadAppBlock(gSocket, gDB, 0, buffer, 0xffff);
+#endif /* defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0) */
/* read in Mail prefs (for signature, filter settings, etc) */
if (0 < dlp_ReadAppPreference(gSocket, makelong("mail"), mailPrefLocal, 1,
+#if defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0)
+ bufsize, pi_buf->data, &size, &version) ) {
+ unpack_MailSyncPref(&gPrefs, pi_buf->data, bufsize);
+#else
bufsize, buffer, &size, &version) ) {
unpack_MailSyncPref(&gPrefs, buffer, bufsize);
+#endif /* defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0) */
#ifdef DEBUG
printf("gPrefs.syncType = %i\n", gPrefs.syncType);
@@ -149,8 +169,14 @@
/* read in Mail's signature info */
if (0 < dlp_ReadAppPreference(gSocket, makelong("mail"), mailPrefSig, 1,
+#if defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0)
+ bufsize, pi_buf->data, 0, 0) ) {
+ unpack_MailSignaturePref(&gSig, pi_buf->data, bufsize);
+#else
bufsize, buffer, 0, 0) ) {
unpack_MailSignaturePref(&gSig, buffer, bufsize);
+#endif /* defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0) */
+
}
}
if (gLocalHack) {
@@ -165,16 +191,28 @@
/* load all Palm emails into memory to compare for dups later */
initStore();
- for (i=0; 0 < dlp_ReadRecordByIndex(gSocket, gDB, i, buffer, &id,
+#if defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0)
+ for (i=0; 0 < dlp_ReadRecordByIndex(gSocket, gDB, i, pi_buf->data, &id,
+ &attr, &cat); i++) {
+ size=pi_buf->used;
+#else
+ for (i=0; 0 < dlp_ReadRecordByIndex(gSocket, gDB, i, buffer, &id,
&size, &attr, &cat); i++) {
+#endif /* defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0) */
struct Mail *mail = (struct Mail *)malloc(sizeof(struct Mail));
/* deleted and archived records already deleted */
+#if defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0)
+ unpack_Mail(mail, pi_buf->data, size);
+#else
unpack_Mail(mail, buffer, size);
+#endif /* defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0) */
+
storeMsg(mail);
}
}
+ pi_buffer_free(pi_buf);
}
/* CloseMailDB()
--- util.c
+++ util.c
@@ -50,7 +50,7 @@
int Connect(char *device)
{
struct pi_sockaddr addr;
- int ret, pilot_socket;
+ int ret, pilot_socket = 0;
#if PILOT_LINK_VERSION > 0 || PILOT_LINK_MAJOR > 11
@@ -61,13 +61,18 @@
}
addr.pi_family = PI_AF_PILOT;
#endif
- strcpy(addr.pi_device, device);
fprintf(stderr, "Waiting for connection on %s (press the HotSync button now)...\n",
device);
-
- ret = pi_bind(pilot_socket, (struct sockaddr*)&addr, sizeof(addr));
- if (ret == -1) {
+
+#if defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0)
+ ret = pi_bind(pilot_socket, device);
+#else
+ strcpy(addr.pi_device, device);
+ ret = pi_bind(pilot_socket, (struct sockaddr*)&addr, sizeof(addr));
+#endif /* defined(PILOT_LINK_IS) && PILOT_LINK_IS(0,12,0) */
+
+ if (ret < 0) {
fprintf(stderr, "Unable to bind to port '%s'.\n", device);
exit(1);
}