summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-06 16:20:25 (UTC)
committer zautrix <zautrix>2004-10-06 16:20:25 (UTC)
commit656636acfb8c607901c97c4f55129e29e1df9913 (patch) (side-by-side diff)
tree25efd61a6b691822a11f43719efcbf69ce7d5c25
parenta22de800110d8350a5200a994b041e47d51bf4c6 (diff)
downloadkdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.zip
kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.tar.gz
kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.tar.bz2
more fixes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp32
-rw-r--r--korganizer/mainwindow.cpp3
-rw-r--r--libkcal/libkcal.pro2
-rw-r--r--libkcal/libkcalE.pro2
-rw-r--r--libkcal/phoneformat.cpp117
-rw-r--r--libkcal/phoneformat.h1
6 files changed, 21 insertions, 136 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 185cf46..7bec90a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,137 +1,138 @@
/*
This file is part of KAddressbook.
Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
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.
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>
#include <kabc/resource.h>
#include <kabc/vcardconverter.h>
#include <kapplication.h>
#include <kactionclasses.h>
#include <kcmultidialog.h>
#include <kdebug.h>
#include <kdeversion.h>
#include <kkeydialog.h>
#include <kmessagebox.h>
#include <kprinter.h>
#include <kprotocolinfo.h>
#include <kresources/selectdialog.h>
#include <kstandarddirs.h>
#include <ktempfile.h>
#include <kxmlguiclient.h>
#include <kaboutdata.h>
#include <libkdepim/categoryselectdialog.h>
#include "addresseeutil.h"
#include "addresseeeditordialog.h"
#include "extensionmanager.h"
#include "kstdaction.h"
#include "kaddressbookservice.h"
#include "ldapsearchdialog.h"
#include "printing/printingwizard.h"
#else // KAB_EMBEDDED
#include <kapplication.h>
#include "KDGanttMinimizeSplitter.h"
#include "kaddressbookmain.h"
#include "kactioncollection.h"
#include "addresseedialog.h"
//US
#include <addresseeview.h>
#include <qapp.h>
#include <qmenubar.h>
//#include <qtoolbar.h>
#include <qmessagebox.h>
#include <kdebug.h>
#include <kiconloader.h> // needed for SmallIcon
#include <kresources/kcmkresources.h>
#include <ktoolbar.h>
//#include <qlabel.h>
#ifndef DESKTOP_VERSION
#include <qpe/ir.h>
#include <qpe/qpemenubar.h>
#include <qtopia/qcopenvelope_qws.h>
#else
#include <qmenubar.h>
#endif
#endif // KAB_EMBEDDED
#include "kcmconfigs/kcmkabconfig.h"
#include "kcmconfigs/kcmkdepimconfig.h"
#include "kpimglobalprefs.h"
#include "externalapphandler.h"
#include <kresources/selectdialog.h>
#include <kmessagebox.h>
#include <picture.h>
#include <resource.h>
//US#include <qsplitter.h>
#include <qmap.h>
#include <qdir.h>
#include <qfile.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qclipboard.h>
#include <qtextstream.h>
#include <libkdepim/categoryselectdialog.h>
#include <kabc/vcardconverter.h>
#include "addresseeutil.h"
@@ -580,256 +581,251 @@ void KABCore::sendMail( const QString& emaillist )
void KABCore::mailVCard()
{
QStringList uids = mViewManager->selectedUids();
if ( !uids.isEmpty() )
mailVCard( uids );
}
void KABCore::mailVCard( const QStringList& uids )
{
QStringList urls;
// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
QString dirName = "/tmp/" + KApplication::randomString( 8 );
QDir().mkdir( dirName, true );
for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
KABC::Addressee a = mAddressBook->findByUid( *it );
if ( a.isEmpty() )
continue;
QString name = a.givenName() + "_" + a.familyName() + ".vcf";
QString fileName = dirName + "/" + name;
QFile outFile(fileName);
if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
KABC::VCardConverter converter;
QString vcard;
converter.addresseeToVCard( a, vcard );
QTextStream t( &outFile ); // use a text stream
t.setEncoding( QTextStream::UnicodeUTF8 );
t << vcard;
outFile.close();
urls.append( fileName );
}
}
bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
/*US
kapp->invokeMailer( QString::null, QString::null, QString::null,
QString::null, // subject
QString::null, // body
QString::null,
urls ); // attachments
*/
}
/**
Beams the "WhoAmI contact.
*/
void KABCore::beamMySelf()
{
KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
if (!a.isEmpty())
{
QStringList uids;
uids << a.uid();
beamVCard(uids);
} else {
KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
}
}
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;
-
-
-
- QString fileName = "/tmp/kapibeamfile.vcf";
-
-
- //QDir().mkdir( dirName, true );
-
+#ifdef _WIN32_
+ QString fileName = locateLocal("tmp", "tempfile.vcf");
+#else
+ QString fileName = "/tmp/kdepimtemp.vcf";
+#endif
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();
QString vcard;
converter.addresseeToVCard( a, vcard );
int start = 0;
int next;
while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
int semi = vcard.find(";", next);
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()
{
QStringList uids = mViewManager->selectedUids();
if ( !uids.isEmpty() )
beamVCard( uids );
}
void KABCore::beamVCard(const QStringList& uids)
{
/*US
QString beamFilename;
Opie::OPimContact c;
if ( actionPersonal->isOn() ) {
beamFilename = addressbookPersonalVCardName();
if ( !QFile::exists( beamFilename ) )
return; // can't beam a non-existent file
Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
beamFilename );
Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
Opie::OPimContactAccess::List allList = access->allRecords();
Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
c = *it;
delete access;
} else {
unlink( beamfile ); // delete if exists
mkdir("/tmp/obex/", 0755);
c = m_abView -> currentEntry();
Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
beamfile );
Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
access->add( c );
access->save();
delete access;
beamFilename = beamfile;
}
owarn << "Beaming: " << beamFilename << oendl;
*/
#if 0
QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
QString name = "contact.vcf";
QString fileName = dirName + "/" + name;
#endif
// LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
//
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();
QString vcard;
converter.addresseeToVCard( a, vcard );
int start = 0;
int next;
while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
int semi = vcard.find(";", next);
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;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2f286e0..ec69b11 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,137 +1,138 @@
#include <stdlib.h>
#include <qaction.h>
#include <qpopupmenu.h>
#include <qpainter.h>
#include <qwhatsthis.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qtextcodec.h>
#include <qfile.h>
#include <qdir.h>
#include <qapp.h>
#include <qfileinfo.h>
#include <qlabel.h>
#include <qspinbox.h>
#include <qcheckbox.h>
#include <qmap.h>
#include <qwmatrix.h>
#include <qtextbrowser.h>
#include <qtextstream.h>
#ifndef DESKTOP_VERSION
#include <qpe/global.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qtopia/alarmserver.h>
#include <qtopia/qcopenvelope_qws.h>
#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"
#include "kstandarddirs.h"
#include "koprefs.h"
#include "kfiledialog.h"
#include "koglobals.h"
#include "kglobal.h"
#include "klocale.h"
#include "kconfig.h"
#include "simplealarmclient.h"
#include "externalapphandler.h"
using namespace KCal;
#ifndef _WIN32_
#include <unistd.h>
#else
#include "koimportoldialog.h"
#endif
#include "mainwindow.h"
class KOex2phonePrefs : public QDialog
{
public:
KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
QDialog( parent, name, true )
{
setCaption( i18n("Export to phone options") );
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setSpacing( 3 );
lay->setMargin( 3 );
QLabel *lab;
lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
lab->setAlignment (AlignHCenter );
QHBox* temphb;
temphb = new QHBox( this );
new QLabel( i18n("I/O device: "), temphb );
mPhoneDevice = new QLineEdit( temphb);
lay->addWidget( temphb );
temphb = new QHBox( this );
new QLabel( i18n("Connection: "), temphb );
mPhoneConnection = new QLineEdit( temphb);
lay->addWidget( temphb );
temphb = new QHBox( this );
new QLabel( i18n("Model(opt.): "), temphb );
mPhoneModel = new QLineEdit( temphb);
lay->addWidget( temphb );
mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
mWriteBackFuture->setChecked( true );
lay->addWidget( mWriteBackFuture );
temphb = new QHBox( this );
new QLabel( i18n("Max. weeks in future: ") , temphb );
mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
mWriteBackFutureWeeks->setValue( 8 );
lay->addWidget( temphb );
lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
lab->setAlignment (AlignHCenter );
QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
lay->addWidget( ok );
QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
lay->addWidget( cancel );
connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
resize( 220, 240 );
}
public:
QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
QCheckBox* mWriteBackFuture;
QSpinBox* mWriteBackFutureWeeks;
};
int globalFlagBlockStartup;
MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
QMainWindow( parent, name )
{
mPassWordPiSync = "abc";
#ifdef DESKTOP_VERSION
setFont( QFont("Arial"), 14 );
#endif
mSyncActionDialog = 0;
mServerSocket = 0;
mClosed = false;
//QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
QString confFile = locateLocal("config","korganizerrc");
QFileInfo finf ( confFile );
@@ -1140,193 +1141,193 @@ void MainWindow::slotSyncMenu( int action )
if ( action == 1000 ) {
syncSharp();
} else if ( action == 1001 ) {
syncLocalFile();
} else if ( action == 1002 ) {
quickSyncLocalFile();
} else if ( action >= 1003 ) {
if ( temp->getIsLocalFileSync() ) {
if ( syncWithFile( temp->getRemoteFileName( ), false ) )
KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
} else {
if ( temp->getIsPhoneSync() ) {
KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
syncPhone();
} else if ( temp->getIsPiSync() ) {
mPassWordPiSync = temp->getRemotePw();
KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
syncPi();
} else
syncRemote( temp );
}
}
delete temp;
mBlockSaveFlag = false;
}
void MainWindow::exportToPhone( int mode )
{
//ex2phone->insertItem(i18n("Complete calendar..."), 1 );
//ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
KOex2phonePrefs ex2phone;
ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
if ( mode == 1 )
ex2phone.setCaption(i18n("Export complete calendar"));
if ( mode == 2 )
ex2phone.setCaption(i18n("Export filtered calendar"));
if ( !ex2phone.exec() ) {
return;
}
KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
int inFuture = 0;
if ( ex2phone.mWriteBackFuture->isChecked() )
inFuture = ex2phone.mWriteBackFutureWeeks->value();
QPtrList<Incidence> delSel;
if ( mode == 1 )
delSel = mCalendar->rawIncidences();
if ( mode == 2 )
delSel = mCalendar->incidences();
CalendarLocal* cal = new CalendarLocal();
cal->setLocalTime();
Incidence *incidence = delSel.first();
QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
while ( incidence ) {
if ( incidence->type() != "Journal" ) {
bool add = true;
if ( inFuture ) {
QDateTime dt;
if ( incidence->type() == "Todo" ) {
Todo * t = (Todo*)incidence;
if ( t->hasDueDate() )
dt = t->dtDue();
else
dt = cur.addSecs( 62 );
}
else {
bool ok;
dt = incidence->getNextOccurence( cur, &ok );
if ( !ok )
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;
}
void MainWindow::setDefaultPreferences()
{
KOPrefs *p = KOPrefs::instance();
p->mCompactDialogs = true;
p->mConfirm = true;
// p->mEnableQuickTodo = false;
}
QString MainWindow::resourcePath()
{
return KGlobal::iconLoader()->iconPath();
}
void MainWindow::displayText( QString text ,QString cap )
{
QDialog dia( this, "name", true ); ;
dia.setCaption( cap );
QVBoxLayout* lay = new QVBoxLayout( &dia );
lay->setSpacing( 3 );
lay->setMargin( 3 );
QTextBrowser tb ( &dia );
lay->addWidget( &tb );
tb.setText( text );
#ifdef DESKTOP_VERSION
dia.resize( 640, 480);
#else
dia.showMaximized();
#endif
dia.exec();
}
void MainWindow::displayFile( QString fn, QString cap )
{
QString fileName = resourcePath() + fn;
QString text;
QFile file( fileName );
if (!file.open( IO_ReadOnly ) ) {
return ;
}
QTextStream ts( &file );
text = ts.read();
file.close();
displayText( text, cap);
}
void MainWindow::features()
{
displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
}
void MainWindow::usertrans()
{
displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
}
void MainWindow::synchowto()
{
#if 0
QPtrList<Incidence> er = mCalendar->rawIncidences();
Incidence* inR = er.first();
VCalFormat vf;
QString strout;
while ( inR ) {
if ( inR->type() == "Todo" )
strout = vf.todoToString( (Todo *) inR );
if ( inR->type() == "Event" )
strout = vf.eventToString( (Event *) inR );
qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
inR = er.next();
}
#endif
displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
}
void MainWindow::faq()
{
displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
}
void MainWindow::whatsNew()
{
displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
diff --git a/libkcal/libkcal.pro b/libkcal/libkcal.pro
index 7a0bd22..171c726 100644
--- a/libkcal/libkcal.pro
+++ b/libkcal/libkcal.pro
@@ -1,103 +1,103 @@
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: {
DEFINES += _WIN32_
LIBS += ../libical/lib/ical.lib
LIBS += ../libical/lib/icalss.lib
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
}
INTERFACES = \
HEADERS = \
alarm.h \
attachment.h \
attendee.h \
calendar.h \
calendarlocal.h \
calfilter.h \
calformat.h \
calstorage.h \
compat.h \
customproperties.h \
dummyscheduler.h \
kincidenceformatter.h \
duration.h \
event.h \
exceptions.h \
filestorage.h \
freebusy.h \
icaldrag.h \
icalformat.h \
icalformatimpl.h \
imipscheduler.h \
incidence.h \
incidencebase.h \
journal.h \
period.h \
person.h \
qtopiaformat.h \
recurrence.h \
scheduler.h \
todo.h \
vcaldrag.h \
vcalformat.h \
versit/port.h \
versit/vcc.h \
versit/vobject.h \
phoneformat.h \
SOURCES = \
alarm.cpp \
attachment.cpp \
attendee.cpp \
calendar.cpp \
calendarlocal.cpp \
calfilter.cpp \
calformat.cpp \
compat.cpp \
customproperties.cpp \
dummyscheduler.cpp \
kincidenceformatter.cpp \
duration.cpp \
event.cpp \
exceptions.cpp \
filestorage.cpp \
freebusy.cpp \
icaldrag.cpp \
icalformat.cpp \
icalformatimpl.cpp \
imipscheduler.cpp \
incidence.cpp \
incidencebase.cpp \
journal.cpp \
period.cpp \
person.cpp \
qtopiaformat.cpp \
recurrence.cpp \
scheduler.cpp \
todo.cpp \
vcaldrag.cpp \
vcalformat.cpp \
versit/vcc.c \
diff --git a/libkcal/libkcalE.pro b/libkcal/libkcalE.pro
index e379b95..e42dc9c 100644
--- a/libkcal/libkcalE.pro
+++ b/libkcal/libkcalE.pro
@@ -1,91 +1,91 @@
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 \
attachment.h \
attendee.h \
calendar.h \
calendarlocal.h \
calfilter.h \
calformat.h \
calstorage.h \
compat.h \
customproperties.h \
dummyscheduler.h \
duration.h \
event.h \
exceptions.h \
filestorage.h \
freebusy.h \
icaldrag.h \
icalformat.h \
icalformatimpl.h \
imipscheduler.h \
incidence.h \
incidencebase.h \
kincidenceformatter.h \
journal.h \
period.h \
person.h \
qtopiaformat.h \
sharpformat.h \
phoneformat.h \
recurrence.h \
scheduler.h \
todo.h \
vcaldrag.h \
vcalformat.h \
versit/port.h \
versit/vcc.h \
versit/vobject.h \
SOURCES = \
alarm.cpp \
attachment.cpp \
attendee.cpp \
calendar.cpp \
calendarlocal.cpp \
calfilter.cpp \
calformat.cpp \
compat.cpp \
customproperties.cpp \
dummyscheduler.cpp \
duration.cpp \
event.cpp \
exceptions.cpp \
filestorage.cpp \
freebusy.cpp \
icaldrag.cpp \
icalformat.cpp \
icalformatimpl.cpp \
imipscheduler.cpp \
incidence.cpp \
incidencebase.cpp \
kincidenceformatter.cpp \
journal.cpp \
period.cpp \
person.cpp \
qtopiaformat.cpp \
sharpformat.cpp \
phoneformat.cpp \
recurrence.cpp \
scheduler.cpp \
todo.cpp \
vcaldrag.cpp \
vcalformat.cpp \
versit/vcc.c \
versit/vobject.c \
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index b2a62b1..c39413e 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,287 +1,190 @@
/*
This file is part of libkcal.
Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qdatetime.h>
#include <qstring.h>
#include <qapplication.h>
#include <qptrlist.h>
#include <qregexp.h>
#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
{
public:
PhoneParser( ) {
;
}
static QString dtToString( const QDateTime& dti, bool useTZ = false )
{
QString datestr;
QString timestr;
int offset = KGlobal::locale()->localTimeOffset( dti );
QDateTime dt;
if (useTZ)
dt = dti.addSecs ( -(offset*60));
else
dt = dti;
if(dt.date().isValid()){
const QDate& date = dt.date();
datestr.sprintf("%04d%02d%02d",
date.year(), date.month(), date.day());
}
if(dt.time().isValid()){
const QTime& time = dt.time();
timestr.sprintf("T%02d%02d%02d",
time.hour(), time.minute(), time.second());
}
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 );
}
if ( ! mDevice.isEmpty() ) {
cfg->Device = strdup(mDevice.latin1());
cfg->DefaultDevice = false;
qDebug("Device set %s ", cfg->Device);
}
if ( ! mModel.isEmpty() ) {
strcpy(cfg->Model,mModel.latin1() );
cfg->DefaultModel = false;
qDebug("Model set %s ",cfg->Model );
}
int error=GSM_InitConnection(s,3);
return error;
}
#endif
ulong PhoneFormat::getCsumTodo( Todo* todo )
{
QStringList attList;
if ( todo->hasDueDate() )
attList << PhoneParser::dtToString ( todo->dtDue() );
attList << todo->summary();
QString completedString = "no";
if ( todo->isCompleted() )
completedString = "yes";
attList << completedString;
int prio = todo->priority();
if( prio == 2 ) prio = 1;
if (prio == 4 ) prio = 5 ;
attList << QString::number( prio );
QString alarmString = "na";
Alarm *alarm;
if ( todo->alarms().count() > 0 ) {
alarm = todo->alarms().first();
if ( alarm->enabled() ) {
alarmString = QString::number(alarm->offset() );
}
}
attList << alarmString;
attList << todo->categoriesStr();
attList << todo->secrecyStr();
return PhoneFormat::getCsum(attList );
}
ulong PhoneFormat::getCsumEvent( Event* event )
{
QStringList attList;
attList << PhoneParser::dtToString ( event->dtStart() );
attList << PhoneParser::dtToString ( event->dtEnd() );
attList << event->summary();
attList << event->location();
QString alarmString = "na";
Alarm *alarm;
if ( event->alarms().count() > 0 ) {
alarm = event->alarms().first();
if ( alarm->enabled() ) {
alarmString = QString::number( alarm->offset() );
}
}
attList << alarmString;
Recurrence* rec = event->recurrence();
QStringList list;
bool writeEndDate = false;
switch ( rec->doesRecur() )
{
case Recurrence::rDaily: // 0
list.append( "0" );
list.append( QString::number( rec->frequency() ));//12
list.append( "0" );
list.append( "0" );
writeEndDate = true;
break;
case Recurrence::rWeekly:// 1
list.append( "1" );
list.append( QString::number( rec->frequency()) );//12
list.append( "0" );
{
int days = 0;
QBitArray weekDays = rec->days();
int i;
for( i = 1; i <= 7; ++i ) {
if ( weekDays[i-1] ) {
days += 1 << (i-1);
}
}
@@ -497,207 +400,193 @@ void PhoneFormat::copyEvent( Event* to, Event* from )
QString nCat;
int iii;
for ( iii = 0; iii < catFrom.count();++iii ) {
nCat = catFrom[iii];
if ( !nCat.isEmpty() )
if ( !cat.contains( nCat )) {
cat << nCat;
}
}
to->setCategories( cat );
Recurrence * r = new Recurrence( *from->recurrence(),to);
to->setRecurrence( r ) ;
}
void PhoneFormat::copyTodo( Todo* to, Todo* from )
{
if ( from->dtStart().isValid() )
to->setDtStart( from->dtStart() );
if ( from->dtDue().isValid() )
to->setDtDue( from->dtDue() );
if ( !from->location().isEmpty() )
to->setLocation( from->location() );
if ( !from->description().isEmpty() )
to->setDescription( from->description() );
if ( !from->summary().isEmpty() )
to->setSummary( from->summary() );
if ( from->alarms().count() ) {
to->clearAlarms();
Alarm *a = from->alarms().first();
Alarm *b = to->newAlarm( );
b->setEnabled( a->enabled() );
if ( a->hasStartOffset() )
b->setStartOffset( a->startOffset() );
if ( a->hasTime() )
b->setTime( a->time() );
}
QStringList cat = to->categories();
QStringList catFrom = from->categories();
QString nCat;
int iii;
for ( iii = 0; iii < catFrom.count();++iii ) {
nCat = catFrom[iii];
if ( !nCat.isEmpty() )
if ( !cat.contains( nCat )) {
cat << nCat;
}
}
to->setCategories( cat );
if ( from->isCompleted() ) {
to->setCompleted( true );
if( from->completed().isValid() )
to->setCompleted( from->completed() );
} else {
// set percentcomplete only, if to->isCompleted()
if ( to->isCompleted() )
to->setPercentComplete(from->percentComplete());
}
if( to->priority() == 2 && from->priority() == 1 )
; //skip
else if (to->priority() == 4 && from->priority() == 5 )
;
else
to->setPriority(from->priority());
}
#include <qcstring.h>
void PhoneFormat::afterSave( Incidence* inc)
{
uint csum;
inc->removeID( mProfileName );
if ( inc->type() == "Event")
csum = PhoneFormat::getCsumEvent( (Event*) inc );
else
csum = PhoneFormat::getCsumTodo( (Todo*) inc );
inc->setCsum( mProfileName, QString::number( csum ));
inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
}
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();
status.raise();
qApp->processEvents();
QString message;
// 1 remove events which should be deleted
QPtrList<Event> er = calendar->rawEvents();
Event* ev = er.first();
while ( ev ) {
if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
calendar->deleteEvent( ev );
} else {
}
ev = er.next();
}
// 2 remove todos which should be deleted
QPtrList<Todo> tl = calendar->rawTodos();
Todo* to = tl.first();
while ( to ) {
if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
calendar->deleteTodo( to );
} else {
if ( to->isCompleted()) {
calendar->deleteTodo( to );
}
}
to = tl.next();
}
// 3 save file
if ( !writeToPhone( calendar ) )
return false;
// 5 reread data
message = i18n(" Rereading all data ... ");
status.setText ( message );
qApp->processEvents();
CalendarLocal* calendarTemp = new CalendarLocal();
calendarTemp->setTimeZoneId( calendar->timeZoneId());
if ( ! load( calendarTemp,calendar) ){
qDebug("error reloading calendar ");
delete calendarTemp;
return false;
}
// 6 compare data
//algo 6 compare event
er = calendar->rawEvents();
ev = er.first();
message = i18n(" Comparing event # ");
QPtrList<Event> er1 = calendarTemp->rawEvents();
Event* ev1;
int procCount = 0;
while ( ev ) {
//qDebug("event new ID %s",ev->summary().latin1());
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
uint csum;
csum = PhoneFormat::getCsumEvent( ev );
QString cSum = QString::number( csum );
//ev->setCsum( mProfileName, cSum );
//qDebug("Event cSum %s ", cSum.latin1());
ev1 = er1.first();
while ( ev1 ) {
if ( ev1->getCsum( mProfileName ) == cSum ) {
er1.remove( ev1 );
afterSave( ev );
ev->setID(mProfileName, ev1->getID(mProfileName) );
//qDebug("Event found on phone for %s ", ev->summary().latin1());
break;
}
ev1 = er1.next();
}
if ( ! ev1 ) {
// ev->removeID(mProfileName);
qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
}
ev = er.next();
}
//algo 6 compare todo
tl = calendar->rawTodos();
to = tl.first();
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 61e8160..001fd81 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,63 +1,62 @@
/*
This file is part of libkcal.
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef PHONEFORMAT_H
#define PHONEFORMAT_H
#include <qstring.h>
#include "scheduler.h"
#include "vcalformat.h"
#include "calformat.h"
namespace KCal {
/**
This class implements the calendar format used by Phone.
*/
class Event;
class Todo;
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