Update of /cvsroot/mahogany/M/src/modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11759/src/modules
Modified Files:
PalmOS.cpp
Log Message:
fixed compilation of PalmOS module
Index: PalmOS.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/PalmOS.cpp,v
retrieving revision 1.120
retrieving revision 1.121
diff -b -u -2 -r1.120 -r1.121
--- PalmOS.cpp 24 Nov 2003 12:55:11 -0000 1.120
+++ PalmOS.cpp 8 Jul 2004 21:46:27 -0000 1.121
@@ -43,4 +43,5 @@
# include <wx/menu.h>
# include <wx/log.h>
+# include <wx/filedlg.h>
#endif // USE_PCH
@@ -62,4 +63,8 @@
#endif
+#include <wx/dir.h>
+
+#include "adb/AdbManager.h"
+#include "adb/ProvPalm.h"
#ifdef HAVE_LIBMAL
@@ -74,4 +79,9 @@
#undef PALMOS_SYNCTIME
+// one of pisock headers defines struct Address and MInterface.h below
+// includes our Address.h which defines class Address, so define this to
+// prevent our Address from being defined now
+#define M_DONT_DEFINE_ADDRESS
+
#include "MModule.h"
#include "Mversion.h"
@@ -86,7 +96,4 @@
#include "gui/wxMDialogs.h"
-#include "adb/AdbManager.h"
-#include "adb/ProvPalm.h"
-
#define MODULE_NAME "PalmOS"
@@ -334,5 +341,5 @@
int createEntries(int db, struct AddressAppInfo * aai, PalmEntryGroup* p_Group);
- int CreateFileList(wxArrayString &list, DIR * dir, wxString directory);
+ int CreateFileList(wxArrayString &list, const wxString& directory);
void RemoveFromList(wxArrayString &list, wxString &name)
{ if (list.Index(name) >= 0) list.Remove(list.Index(name)); }
@@ -741,5 +748,5 @@
return false;
- if (!(m_PiSocket = pi_socket(PI_AF_SLP, PI_SOCK_STREAM, PI_PF_PADP)))
+ if (!(m_PiSocket = pi_socket(PI_AF_PILOT, PI_SOCK_STREAM, PI_PF_PADP)))
{
ErrorMessage(_("Failed to connect to PalmOS device:\nCould not open
socket."));
@@ -748,5 +755,5 @@
}
- addr.pi_family = PI_AF_SLP;
+ addr.pi_family = PI_AF_PILOT;
strncpy(addr.pi_device,
m_PilotDev.c_str(),
@@ -939,8 +946,10 @@
int
-PalmOSModule::CreateFileList(wxArrayString &list, DIR * dir,
- wxString directory)
+PalmOSModule::CreateFileList(wxArrayString &list, const wxString& directory)
{
- struct dirent * dirent;
+ wxDir dir;
+ if ( !dir.Open(directory) )
+ return -1;
+
int filecount = 0;
@@ -948,27 +957,8 @@
StatusMessage(_("Reading local directory ..."));
- while( (dirent = readdir(dir)) ) {
wxString name;
-
- // ignore .* files (especially . or ..)
- if (dirent->d_name[0] == '.')
- continue;
-// this test is broken and needs to be replaced with stat()
-#undef _DIRENT_HAVE_D_TYPE
-#ifdef _DIRENT_HAVE_D_TYPE
- // ignore directories
- if ( (dirent->d_type & DT_REG) == 0
- && (dirent->d_type & DT_LNK) == 0
- && (dirent->d_type & DT_UNKNOWN) == 0 )
+ for ( bool cont = dir.GetFirst(&name); cont; cont = dir.GetNext(&name) )
{
- wxString msg;
- msg.Printf(_("Ignoring entry '%s' which is not a regular file."),
- dirent->d_name);
- StatusMessage(_(msg));
- continue;
- }
-
-#endif
- name = dirent->d_name;
+ // TODO: check that we got a regular file
wxString extension = name.AfterLast('.');
if(extension != "pdb" && extension != "prc" &&
@@ -983,5 +973,6 @@
// now we need the full pathname:
- name.Printf("%s%s", directory.c_str(), dirent->d_name);
+ name = directory + '/' + name;
+
// now we open the file and see whether it is really a file for
// the Palm. If yes, then we remember the filename.
@@ -994,4 +985,5 @@
}
}
+
return filecount;
}
@@ -1053,9 +1045,7 @@
return;
- // access backup directory
- DIR * dir;
- dir = opendir(m_BackupDir);
-
- if (dir <= 0)
+ // Read original list of files in the backup dir
+ wxArrayString orig_files;
+ if ( CreateFileList(orig_files, m_BackupDir) == -1 )
{
String msg;
@@ -1063,13 +1053,6 @@
m_BackupDir.c_str());
ErrorMessage(msg);
- return;
}
- // Read original list of files in the backup dir
- wxArrayString orig_files;
-
- CreateFileList(orig_files, dir, m_BackupDir);
- closedir(dir);
-
// count files on the palm
int max = 0;
@@ -1377,10 +1360,9 @@
return;
- DIR* dir;
- int ofile_total;
wxArrayString fnames;
- dir = opendir(directory);
- if (dir <= 0) {
+ int ofile_total = CreateFileList(fnames, directory);
+ if ( ofile_total == -1 )
+ {
wxString msg;
msg.Printf(_("Could not access directory %s!"),
@@ -1390,9 +1372,4 @@
}
- ofile_total = CreateFileList(fnames, dir, directory);
-
- // we've finished reading the filelist
- closedir(dir);
-
// install files
if (ofile_total > 0)
@@ -1805,5 +1782,5 @@
String mimeType = msg->GetPartMimeType(partNo);
- if ( msg->GetPartType(partNo) == Message::MSG_TYPETEXT &&
+ if ( msg->GetPartType(partNo) == MimeType::TEXT &&
mimeType.Upper() == "TEXT/PLAIN" )
content << (char *)msg->GetPartContent(partNo);
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates