author | zautrix <zautrix> | 2004-10-06 16:20:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-06 16:20:25 (UTC) |
commit | 656636acfb8c607901c97c4f55129e29e1df9913 (patch) (side-by-side diff) | |
tree | 25efd61a6b691822a11f43719efcbf69ce7d5c25 | |
parent | a22de800110d8350a5200a994b041e47d51bf4c6 (diff) | |
download | kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.zip kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.tar.gz kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.tar.bz2 |
more fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 32 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 5 | ||||
-rw-r--r-- | libkcal/libkcal.pro | 2 | ||||
-rw-r--r-- | libkcal/libkcalE.pro | 2 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 117 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 1 |
6 files changed, 22 insertions, 137 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 185cf46..7bec90a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -12,42 +12,43 @@ 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. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ -/* +/*s Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include "kabcore.h" #include <stdaddressbook.h> #include <klocale.h> #include <kfiledialog.h> #include <qtimer.h> #include <qlabel.h> #include <qlineedit.h> #include <qcheckbox.h> #include <qpushbutton.h> #include <qprogressbar.h> +#include <libkdepim/phoneaccess.h> #ifndef KAB_EMBEDDED #include <qclipboard.h> #include <qdir.h> #include <qfile.h> #include <qapplicaton.h> #include <qprogressbar.h> #include <qlayout.h> #include <qregexp.h> #include <qvbox.h> #include <kabc/addresseelist.h> #include <kabc/errorhandler.h> @@ -664,39 +665,39 @@ void KABCore::export2phone() KAex2phonePrefs ex2phone; ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); if ( !ex2phone.exec() ) { return; } KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); -#if 0 - PhoneFormat::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, + + PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, KPimGlobalPrefs::instance()->mEx2PhoneConnection, KPimGlobalPrefs::instance()->mEx2PhoneModel ); + QStringList uids = mViewManager->selectedUids(); + if ( uids.isEmpty() ) + return; +#ifdef _WIN32_ + QString fileName = locateLocal("tmp", "tempfile.vcf"); +#else + QString fileName = "/tmp/kdepimtemp.vcf"; +#endif - - - QString fileName = "/tmp/kapibeamfile.vcf"; - - - //QDir().mkdir( dirName, true ); - - KABC::VCardConverter converter; QString description; QString datastream; for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { KABC::Addressee a = mAddressBook->findByUid( *it ); if ( a.isEmpty() ) continue; if (description.isEmpty()) description = a.formattedName(); @@ -709,43 +710,38 @@ void KABCore::export2phone() int dopp = vcard.find(":", next); int sep; if ( semi < dopp && semi >= 0 ) sep = semi ; else sep = dopp; datastream +=vcard.mid( start, next - start); datastream +=vcard.mid( next+5,sep -next -5 ).upper(); start = sep; } datastream += vcard.mid( start,vcard.length() ); } -#ifndef DESKTOP_VERSION QFile outFile(fileName); if ( outFile.open(IO_WriteOnly) ) { datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); QTextStream t( &outFile ); // use a text stream t.setEncoding( QTextStream::UnicodeUTF8 ); t <<datastream; outFile.close(); - Ir *ir = new Ir( this ); - connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); - ir->send( fileName, description, "text/x-vCard" ); } else { - qDebug("Error open temp beam file "); + qDebug("Error open temp file "); return; } -#endif - +#if 0 setCaption( i18n("Writing to phone...")); if ( PhoneFormat::writeToPhone( cal ) ) setCaption( i18n("Export to phone successful!")); else setCaption( i18n("Error exporting to phone!")); #endif } void KABCore::beamVCard() { diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 2f286e0..ec69b11 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -30,24 +30,25 @@ #include <unistd.h> // for sleep #else #include <qmenubar.h> #include <qtoolbar.h> #include <qapplication.h> //#include <resource.h> #endif #include <libkcal/calendarlocal.h> #include <libkcal/todo.h> #include <libkcal/phoneformat.h> #include <libkdepim/ksyncprofile.h> +#include <libkdepim/phoneaccess.h> #include <libkcal/kincidenceformatter.h> #include <libkdepim/kpimglobalprefs.h> #include "calendarview.h" #include "koviewmanager.h" #include "datenavigator.h" #include "koagendaview.h" #include "koagenda.h" #include "kodialogmanager.h" #include "kdialogbase.h" #include "kapplication.h" #include "kofilterview.h" @@ -1223,26 +1224,26 @@ void MainWindow::exportToPhone( int mode ) dt = cur.addSecs( -62 ); } if ( dt < cur || dt > end ) { add = false; } } if ( add ) { Incidence *in = incidence->clone(); cal->addIncidence( in ); } } incidence = delSel.next(); - } - PhoneFormat::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, + } + PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, KPimGlobalPrefs::instance()->mEx2PhoneConnection, KPimGlobalPrefs::instance()->mEx2PhoneModel ); setCaption( i18n("Writing to phone...")); if ( PhoneFormat::writeToPhone( cal ) ) setCaption( i18n("Export to phone successful!")); else setCaption( i18n("Error exporting to phone!")); delete cal; } diff --git a/libkcal/libkcal.pro b/libkcal/libkcal.pro index 7a0bd22..171c726 100644 --- a/libkcal/libkcal.pro +++ b/libkcal/libkcal.pro @@ -1,19 +1,19 @@ TEMPLATE = lib CONFIG += qt warn_on TARGET = microkcal include( ../variables.pri ) -INCLUDEPATH += ../microkde versit ../microkde/kdecore +INCLUDEPATH += ../libkdepim ../microkde versit ../microkde/kdecore #../qtcompat INCLUDEPATH += ../libical/src/libical INCLUDEPATH += ../libical/src/libicalss DESTDIR = ../bin DEFINES += DESKTOP_VERSION unix: { LIBS += ../libical/lib/libical.a LIBS += ../libical/lib/libicalss.a OBJECTS_DIR = obj/unix MOC_DIR = moc/unix } win32: { diff --git a/libkcal/libkcalE.pro b/libkcal/libkcalE.pro index e379b95..e42dc9c 100644 --- a/libkcal/libkcalE.pro +++ b/libkcal/libkcalE.pro @@ -1,17 +1,17 @@ TEMPLATE = lib CONFIG += qt warn_on TARGET = komicrokcal -INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include +INCLUDEPATH += ../libkdepim ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include INCLUDEPATH += ../libical/src/libical INCLUDEPATH += ../libical/src/libicalss OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR = $(QPEDIR)/lib LIBS += ../libical/lib/$(PLATFORM)/libical.a LIBS += ../libical/lib/$(PLATFORM)/libicalss.a INTERFACES = \ HEADERS = \ alarm.h \ diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index b2a62b1..c39413e 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -27,24 +27,25 @@ #include <qmessagebox.h> #include <qclipboard.h> #include <qfile.h> #include <qtextstream.h> #include <qtextcodec.h> #include <qdir.h> #include <qlabel.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include <kmessagebox.h> +#include <phoneaccess.h> #include "calendar.h" #include "alarm.h" #include "recurrence.h" #include "calendarlocal.h" #include "phoneformat.h" #include "syncdefines.h" using namespace KCal; class PhoneParser : public QObject { @@ -75,129 +76,31 @@ public: } return datestr + timestr; } }; PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) { mProfileName = profileName; - writeConfig( device, connection, model ); + PhoneAccess::writeConfig( device, connection, model ); } PhoneFormat::~PhoneFormat() { } -void PhoneFormat::writeConfig( QString device, QString connection, QString model ) -{ -#ifdef _WIN32_ - QString fileName = qApp->applicationDirPath () +"\\gammurc"; -#else - QString fileName = QDir::homeDirPath() +"/.gammurc"; -#endif - //qDebug("save %d ", load ); - QString content; - bool write = false; - bool addPort = true, addConnection = true, addModel = true; - QFile file( fileName ); - if ( QFile::exists( fileName) ) { - if (!file.open( IO_ReadOnly ) ) { - qDebug("Error: cannot open %s ", fileName.latin1() ); - return; - } - QString line; - while ( file.readLine( line, 1024 ) > 0 ) { - //qDebug("*%s* ", line.latin1() ); - if ( line.left(7 ) == "[gammu]" ) { - ; - } else - if ( line.left(4 ) == "port" ) { - if ( line == "port = " + device+"\n" ) { - content += line ; - addPort = false; - //qDebug("port found" ); - } - - } else if ( line.left(5 ) == "model" ) { - if ( line == "model = " + model +"\n") { - content += line ; - addModel = false; - //qDebug("model found" ); - } - - } else if ( line.left( 10 ) == "connection" ) { - if ( line == "connection = " + connection +"\n") { - addConnection = false; - content += line ; - //qDebug("con found" ); - } - - } else { - content += line ; - } - } - file.close(); - } else { - if ( ! connection.isEmpty() ) { - addConnection = true; - } - if ( ! device.isEmpty() ) { - addPort = true; - } - if ( ! model.isEmpty() ) { - addModel = true; - } - } - - if ( addConnection ) { - if ( ! write ) - content += "[gammu]\n"; - write = true; - content += "connection = "; - content += connection; - content += "\n"; - } - if ( addPort ) { - if ( ! write ) - content += "[gammu]\n"; - write = true; - content += "port = "; - content += device; - content += "\n"; - - } - if ( addModel ) { - if ( ! write ) - content += "[gammu]\n"; - write = true; - content += "model = "; - content += model; - content += "\n"; - } - if ( write ) { - if (!file.open( IO_WriteOnly ) ) { - qDebug("Error: cannot write file %s ", fileName.latin1() ); - return; - } - qDebug("Writing file %s ", fileName.latin1() ); - QTextStream ts( &file ); - ts << content ; - file.close(); - } - -} #if 0 int PhoneFormat::initDevice(GSM_StateMachine *s) { GSM_ReadConfig(NULL, &s->Config[0], 0); s->ConfigNum = 1; GSM_Config *cfg = &s->Config[0]; if ( ! mConnection.isEmpty() ) { cfg->Connection = strdup(mConnection.latin1()); cfg->DefaultConnection = false; qDebug("Connection set %s ", cfg->Connection ); } @@ -581,39 +484,25 @@ void PhoneFormat::afterSave( Incidence* inc) bool PhoneFormat::writeToPhone( Calendar * calendar) { #ifdef _WIN32_ QString fileName = locateLocal("tmp", "tempfile.vcs"); #else QString fileName = "/tmp/kdepimtemp.vcs"; #endif VCalFormat vfsave; vfsave.setLocalTime ( true ); if ( ! vfsave.save( calendar, fileName ) ) return false; - // 4 call kammu -#ifdef DESKTOP_VERSION - QString command ="./kammu --restore " + fileName ; -#else - QString command ="kammu --restore " + fileName ; -#endif - int ret; - while ( (ret = system ( command.latin1())) != 0 ) { - qDebug("Error S::command returned %d. asking users", ret); - int retval = KMessageBox::warningContinueCancel(0, - i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel")); - if ( retval != KMessageBox::Continue ) - return false; - } - return true; + return PhoneAccess::writeToPhone( fileName ); } bool PhoneFormat::save( Calendar *calendar) { QLabel status ( i18n(" Opening device ..."), 0 ); int w = status.sizeHint().width()+20 ; if ( w < 200 ) w = 230; int h = status.sizeHint().height()+20 ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); status.setCaption(i18n("Writing to phone...") ); status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); status.show(); diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 61e8160..001fd81 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h @@ -39,25 +39,24 @@ class PhoneFormat : public QObject { public: /** Create new iCalendar format. */ PhoneFormat(QString profileName, QString device,QString connection, QString model); virtual ~PhoneFormat(); bool load( Calendar * ,Calendar * ); bool save( Calendar * ); bool fromString( Calendar *, const QString & ); QString toString( Calendar * ); static ulong getCsum( const QStringList & ); static ulong getCsumTodo( Todo* to ); static ulong getCsumEvent( Event* ev ); - static void writeConfig( QString device,QString connection, QString model ); static bool writeToPhone( Calendar * ); private: void copyEvent( Event* to, Event* from ); void copyTodo( Todo* to, Todo* from ); //int initDevice(GSM_StateMachine *s); QString mProfileName; void afterSave( Incidence* ); }; } #endif |