summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koprefs.cpp6
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp134
-rw-r--r--korganizer/mainwindow.h1
-rw-r--r--libkcal/phoneformat.cpp68
-rw-r--r--libkcal/phoneformat.h2
6 files changed, 188 insertions, 26 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index c28da9a..716a125 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,175 +1,181 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@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.
*/
#include <time.h>
#ifndef _WIN32_
#include <unistd.h>
#endif
#include <qdir.h>
#include <qtextstream.h>
#include <qtextcodec.h>
#include <qstring.h>
#include <qregexp.h>
#include <qfont.h>
#include <qcolor.h>
#include <qstringlist.h>
#include <stdlib.h>
#include <kglobal.h>
#include <kconfig.h>
#include <klocale.h>
#include <kdebug.h>
#include <kemailsettings.h>
#include <kstaticdeleter.h>
#include <libkdepim/kpimglobalprefs.h>
#include "koprefs.h"
#include "mainwindow.h"
const char *germanwords[][2] = {
#include "wordsgerman.h"
"", ""
};
KOPrefs *KOPrefs::mInstance = 0;
static KStaticDeleter<KOPrefs> insd;
KOPrefs::KOPrefs() :
KPimPrefs("korganizerrc")
{
mCategoryColors.setAutoDelete(true);
mLocaleDict = 0;
fillMailDefaults();
mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
QColor defaultHolidayColor = QColor(255,0,0);
QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
QColor defaultTodoDueTodayColor = QColor(255,220,100);
QColor defaultTodoOverdueColor = QColor(255,153,125);
mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
mDefaultViewFont = QFont("helvetica",10);
mDefaultMonthViewFont = QFont("helvetica",8);
mMarcusBainsFont= QFont("helvetica",10);
mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
mEditBoxFont = QFont("helvetica",12);
mJornalViewFont = QFont("helvetica",12);
KPrefs::setCurrentGroup("General");
+
+
+ addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm");
+ addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda");
+ addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i");
+
addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
addItemBool("ShowIconSearch",&mShowIconSearch,true);
addItemBool("ShowIconList",&mShowIconList,true);
addItemBool("ShowIconDay1",&mShowIconDay1,true);
addItemBool("ShowIconDay5",&mShowIconDay5,true);
addItemBool("ShowIconDay7",&mShowIconDay7,true);
addItemBool("ShowIconMonth",&mShowIconMonth,true);
addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
addItemBool("ShowIconBack",&mShowIconBack,true);
addItemBool("ShowIconToday",&mShowIconToday,true);
addItemBool("ShowIconForward",&mShowIconForward,true);
addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
addItemBool("ShowIconNext",&mShowIconNext,true);
addItemBool("ShowIconJournal",&mShowIconJournal,true);
addItemBool("ShowIconStretch",&mShowIconStretch,true);
addItemBool("LanguageChanged",&mLanguageChanged,false);
addItemBool("AskForQuit",&mAskForQuit,false);
#ifndef DESKTOP_VERSION
addItemBool("ShowFullMenu",&mShowFullMenu,false);
#else
addItemBool("ShowFullMenu",&mShowFullMenu,true);
#endif
addItemBool("ToolBarHor",&mToolBarHor, true );
addItemBool("ToolBarUp",&mToolBarUp, false );
addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
addItemInt("Whats Next Days",&mWhatsNextDays,3);
addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
addItemInt("AllDay Size",&mAllDaySize,28);
QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
addItemStringList("LocationDefaults",&mLocationDefaults );
addItemStringList("EventSummary User",&mEventSummaryUser);
addItemStringList("TodoSummary User",&mTodoSummaryUser);
addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
addItemBool("Enable Project View",&mEnableProjectView,false);
addItemBool("Auto Save",&mAutoSave,false);
addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
addItemBool("Confirm Deletes",&mConfirm,true);
addItemString("Archive File",&mArchiveFile);
addItemString("Html Export File",&mHtmlExportFile,
QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
addItemBool("Html With Save",&mHtmlWithSave,false);
KPrefs::setCurrentGroup("Personal Settings");
addItemInt("Mail Client",&mMailClient,MailClientKMail);
addItemBool("Use Control Center Email",&mEmailControlCenter,false);
addItemBool("Bcc",&mBcc,false);
KPrefs::setCurrentGroup("Time & Date");
// addItemString("Time Zone",&mTimeZone,"+0100");
addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
// addItemInt("TimeZoneOffset",&mTimeZoneOffset,60);
addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
addItemInt("Default Start Time",&mStartTime,10);
addItemInt("Default Duration",&mDefaultDuration,2);
addItemInt("Default Alarm Time",&mAlarmTime,3);
addItemInt("Daylight Savings",&mDaylightSavings,0);
KPrefs::setCurrentGroup("AlarmSettings");
addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
KPrefs::setCurrentGroup("Calendar");
addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
KPrefs::setCurrentGroup("Fonts");
// qDebug(" KPrefs::setCurrentGroup(Fonts); ");
addItemFont("TimeBar Font",&mTimeBarFont);
addItemFont("MonthView Font",&mMonthViewFont);
addItemFont("AgendaView Font",&mAgendaViewFont);
addItemFont("MarcusBains Font",&mMarcusBainsFont);
addItemFont("TimeLabels Font",&mTimeLabelsFont);
addItemFont("TodoView Font",&mTodoViewFont);
addItemFont("ListView Font",&mListViewFont);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index d9ac851..a1ba8b3 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -117,192 +117,195 @@ class KOPrefs : public KPimPrefs
QFont mTodoViewFont;
QFont mListViewFont;
QFont mDateNavigatorFont;
QFont mEditBoxFont;
QFont mJornalViewFont;
QFont mWhatsNextFont;
QFont mEventViewFont;
QColor mHolidayColor;
QColor mHighlightColor;
QColor mEventColor;
QColor mAgendaBgColor;
QColor mWorkingHoursColor;
QColor mTodoDueTodayColor;
QColor mTodoOverdueColor;
QColor mMonthViewEvenColor;
QColor mMonthViewOddColor;
QColor mMonthViewHolidayColor;
bool mMonthViewUsesDayColors;
bool mMonthViewSatSunTog;
QColor mAppColor1;
QColor mAppColor2;
bool mUseAppColors;
int mDayBegins;
int mHourSize;
int mAllDaySize;
bool mShowFullMenu;
bool mDailyRecur;
bool mWeeklyRecur;
bool mMonthDailyRecur;
bool mMonthWeeklyRecur;
bool mMonthShowIcons;
bool mMonthShowShort;
bool mEnableToolTips;
bool mEnableMonthScroll;
bool mFullViewMonth;
bool mMonthViewUsesCategoryColor;
bool mFullViewTodo;
bool mShowCompletedTodo;
bool mMarcusBainsEnabled;
int mNextXDays;
int mWhatsNextDays;
int mWhatsNextPrios;
bool mEnableQuickTodo;
bool mLanguageChanged;
bool mCompactDialogs;
bool mVerticalScreen;
bool mShowIconNewTodo;
bool mShowIconNewEvent;
bool mShowIconSearch;
bool mShowIconList;
bool mShowIconDay1;
bool mShowIconDay5;
bool mShowIconDay7;
bool mShowIconMonth;
bool mShowIconTodoview;
bool mShowIconBackFast;
bool mShowIconBack;
bool mShowIconToday;
bool mShowIconForward;
bool mShowIconForwardFast;
bool mShowIconWhatsThis;
bool mShowIconNextDays;
bool mShowIconNext;
bool mShowIconJournal;
bool mShowIconStretch;
bool mToolBarHor;
bool mToolBarUp;
bool mToolBarMiniIcons;
bool mAskForQuit;
bool mUsePassWd;
bool mWriteBackFile;
int mWriteBackInFuture;
bool mAskForPreferences;
bool mShowSyncSummary;
bool mShowSyncEvents;
bool mShowTodoInAgenda;
bool mWriteBackExistingOnly;
QString mRemoteIP;
QString mRemoteUser;
QString mRemotePassWd;
QString mRemoteFile;
QString mLocalTempFile;
QString mPhoneDevice;
QString mPhoneConnection;
QString mPhoneModel;
+ QString mEx2PhoneDevice;
+ QString mEx2PhoneConnection;
+ QString mEx2PhoneModel;
int mLastSyncTime;
int mSyncAlgoPrefs;
int mRingSyncAlgoPrefs;
QStringList mSyncProfileNames;
QStringList mExternSyncProfiles;
QString mLocalMachineName;
void setCategoryColor(QString cat,const QColor & color);
QColor *categoryColor(QString cat);
QString mArchiveFile;
QString mHtmlExportFile;
bool mHtmlWithSave;
QStringList mSelectedPlugins;
QString mLastImportFile;
QString mLastVcalFile;
QString mLastSaveFile;
QString mLastLoadFile;
QString mLastSyncedLocalFile;
QString mDefaultAlarmFile;
int mIMIPScheduler;
int mIMIPSend;
QStringList mAdditionalMails;
int mIMIPAutoRefresh;
int mIMIPAutoInsertReply;
int mIMIPAutoInsertRequest;
int mIMIPAutoFreeBusy;
int mIMIPAutoFreeBusyReply;
QStringList mTodoTemplates;
QStringList mEventTemplates;
int mDestination;
bool mEditOnDoubleClick;
bool mViewChangeHoldFullscreen;
bool mViewChangeHoldNonFullscreen;
bool mCenterOnCurrentTime;
bool mSetTimeToDayStartAt;
bool mHighlightCurrentDay;
bool mUseHighlightLightColor;
bool mListViewMonthTimespan;
bool mWNViewShowsParents;
bool mWNViewShowLocation;
bool mTodoViewShowsPercentage;
bool mTodoViewUsesCatColors;
bool mTodoViewUsesSmallFont;
bool mTodoViewUsesForegroundColor;
bool mMonthViewUsesForegroundColor;
bool mHightlightDateTimeEdit;
bool mShortDateInViewer;
QStringList mLocationDefaults;
QStringList mEventSummaryUser;
QStringList mTodoSummaryUser;
bool mUseInternalAlarmNotification;
int mAlarmPlayBeeps;
int mAlarmSuspendTime;
int mAlarmSuspendCount;
int mAlarmBeepInterval;
QString mPassiveSyncPort;
QString mPassiveSyncPw;
QString mActiveSyncPort;
QString mActiveSyncIP;
//US I copied the following settings into KPimGlobalPrefs
// that allows us later to easily remove the settings from here.
int mPreferredDate;
QString mUserDateFormatLong;
QString mUserDateFormatShort;
int mPreferredLanguage;
int mPreferredTime;
bool mWeekStartsOnSunday;
QString mTimeZoneId;
bool mUseDaylightsaving;
int mDaylightsavingStart;
int mDaylightsavingEnd;
private:
QDict<QColor> mCategoryColors;
QColor mDefaultCategoryColor;
QFont mDefaultTimeBarFont;
QFont mDefaultViewFont;
QFont mDefaultMonthViewFont;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index de94b8c..ef73a78 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,164 +1,216 @@
#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 <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 );
+
+ lay->addWidget(new QLabel( i18n("Please read phone sync howto to\nknow more about the connection settings."), this ) );
+ 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 );
+ QPushButton * ok = new QPushButton( i18n("Export!"), 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, 220 );
+
+ }
+
+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 );
bool showWarning = !finf.exists();
setIcon(SmallIcon( "ko24" ) );
mBlockAtStartup = true;
mFlagKeyPressed = false;
setCaption("KOrganizer/Pi");
KOPrefs *p = KOPrefs::instance();
KPimGlobalPrefs::instance()->setGlobalConfig();
// if ( QApplication::desktop()->height() > 480 ) {
// if ( p->mHourSize == 4 )
// p->mHourSize = 6;
// }
if ( p->mHourSize > 18 )
p->mHourSize = 18;
QMainWindow::ToolBarDock tbd;
if ( p->mToolBarHor ) {
if ( p->mToolBarUp )
tbd = Bottom;
else
tbd = Top;
}
else {
if ( p->mToolBarUp )
tbd = Right;
else
tbd = Left;
}
if ( KOPrefs::instance()->mUseAppColors )
QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
globalFlagBlockStartup = 1;
iconToolBar = new QPEToolBar( this );
addToolBar (iconToolBar , tbd );
mBlockSaveFlag = false;
mCalendarModifiedFlag = false;
QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
splash->setAlignment ( AlignCenter );
setCentralWidget( splash );
#ifndef DESKTOP_VERSION
showMaximized();
#endif
//qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
setDefaultPreferences();
mCalendar = new CalendarLocal();
mView = new CalendarView( mCalendar, this,"mCalendar " );
mView->hide();
//mView->resize(splash->size() );
initActions();
#ifndef DESKTOP_VERSION
iconToolBar->show();
qApp->processEvents();
#endif
//qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
int vh = height() ;
int vw = width();
//qDebug("Toolbar hei %d ",iconToolBar->height() );
if ( iconToolBar->orientation () == Qt:: Horizontal ) {
vh -= iconToolBar->height();
} else {
vw -= iconToolBar->height();
}
//mView->setMaximumSize( splash->size() );
//mView->resize( splash->size() );
//qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
mView->readSettings();
bool newFile = false;
if( !QFile::exists( defaultFileName() ) ) {
QFileInfo finfo ( defaultFileName() );
QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
qDebug("oldfile %s ", oldFile.latin1());
QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
finfo.setFile( oldFile );
if (finfo.exists() ) {
KMessageBox::information( this, message);
mView->openCalendar( oldFile );
qApp->processEvents();
} else {
oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
finfo.setFile( oldFile );
if (finfo.exists() ) {
KMessageBox::information( this, message);
mView->openCalendar( oldFile );
qApp->processEvents();
@@ -560,192 +612,201 @@ void MainWindow::initActions()
#endif
mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
this );
mNewSubTodoAction->addTo( actionMenu );
connect( mNewSubTodoAction, SIGNAL( activated() ),
mView, SLOT( newSubTodo() ) );
actionMenu->insertSeparator();
mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
mShowAction->addTo( actionMenu );
connect( mShowAction, SIGNAL( activated() ),
mView, SLOT( showIncidence() ) );
mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
mEditAction->addTo( actionMenu );
connect( mEditAction, SIGNAL( activated() ),
mView, SLOT( editIncidence() ) );
mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
mDeleteAction->addTo( actionMenu );
connect( mDeleteAction, SIGNAL( activated() ),
mView, SLOT( deleteIncidence() ) );
actionMenu->insertSeparator();
action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
this );
action->addTo( actionMenu );
connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
icon = loadPixmap( pathString + "search" );
QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
search_action->addTo( actionMenu );
connect( search_action, SIGNAL( activated() ),
mView->dialogManager(), SLOT( showSearchDialog() ) );
icon = loadPixmap( pathString + "today" );
configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
today_action->addTo( actionMenu );
connect( today_action, SIGNAL( activated() ),
mView, SLOT( goToday() ) );
if ( KOPrefs::instance()->mShowFullMenu ) {
actionMenu->insertSeparator();
actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
}
// actionMenu->insertSeparator();
action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
action = new QAction( "import_quick", i18n("Import last file"), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
importMenu->insertSeparator();
action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
#ifndef DESKTOP_VERSION
importMenu->insertSeparator();
action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
#else
#ifdef _WIN32_
importMenu->insertSeparator();
action = new QAction( "import_ol", i18n("Import from OL"), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
#endif
#endif
importMenu->insertSeparator();
action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
importMenu->insertSeparator();
action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
this );
action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
+
+
+ //LR
+ QPopupMenu *ex2phone = new QPopupMenu( this );
+ ex2phone->insertItem(i18n("Complete calendar..."), 1 );
+ ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
+ connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
+ importMenu->insertItem( i18n("Export to phone"), ex2phone );
+
importMenu->insertSeparator();
action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
#ifndef DESKTOP_VERSION
importMenu->insertSeparator();
action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
#else
importMenu->insertSeparator();
icon = loadPixmap( pathString + "print" );
action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ),
this, SLOT( printCal() ) );
icon = loadPixmap( pathString + "print" );
action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ),
this, SLOT( printSel() ) );
#endif
importMenu->insertSeparator();
action = new QAction( "beam all", i18n("Save"), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
action = new QAction( "beam all", i18n("Exit (+save)"), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
//menuBar->insertItem( "Configure",configureMenu );
//configureMenu->insertItem( "Toolbar",configureToolBarMenu );
icon = loadPixmap( "korganizer/korganizer" );
action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
action->addTo( helpMenu );
connect( action, SIGNAL( activated() ),
SLOT( keyBindings() ) );
action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
action->addTo( helpMenu );
connect( action, SIGNAL( activated() ),
SLOT( features() ) );
action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
action->addTo( helpMenu );
connect( action, SIGNAL( activated() ),
SLOT( aboutAutoSaving() ) );
action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
action->addTo( helpMenu );
connect( action, SIGNAL( activated() ),
SLOT( aboutKnownBugs() ) );
action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
action->addTo( helpMenu );
connect( action, SIGNAL( activated() ),
SLOT( usertrans() ) );
action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
action->addTo( helpMenu );
connect( action, SIGNAL( activated() ),
SLOT( synchowto() ) );
action = new QAction( "Whats New", i18n("What's new?"), 0,this );
action->addTo( helpMenu );
connect( action, SIGNAL( activated() ),
SLOT( whatsNew() ) );
action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
action->addTo( helpMenu );
connect( action, SIGNAL( activated() ),
SLOT( faq() ) );
action = new QAction( "about", i18n("About..."), 0, this );
action->addTo( helpMenu );
connect( action, SIGNAL( activated() ),
SLOT( about() ) );
action = new QAction( "licence", i18n("Licence..."), 0, this );
action->addTo( helpMenu );
connect( action, SIGNAL( activated() ),
SLOT( licence() ) );
//menuBar->insertSeparator();
// ******************************************************
// menubar icons
iconToolBar->setHorizontalStretchable (true );
//menuBar->insertItem( iconToolBar );
//xdays_action
if (p-> mShowIconNewEvent)
ne_action->addTo( iconToolBar );
@@ -994,199 +1055,272 @@ void MainWindow::multiSync( bool askforPrefs )
KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
}
setCaption(i18n("Multiple sync started.") );
qApp->processEvents();
int num = ringSync() ;
if ( num > 1 )
ringSync();
mBlockSaveFlag = false;
if ( num )
save();
if ( num )
setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
else
setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
return;
}
void MainWindow::slotSyncMenu( int action )
{
qDebug("syncaction %d ", action);
if ( action == 0 ) {
// seems to be a Qt2 event handling bug
// syncmenu.clear causes a segfault at first time
// when we call it after the main event loop, it is ok
// same behaviour when calling OM/Pi via QCOP for the first time
QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
//confSync();
return;
}
if ( action == 1 ) {
multiSync( true );
return;
}
if ( action == 2 ) {
enableQuick();
QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
return;
}
if ( action == 3 ) {
delete mServerSocket;
mServerSocket = 0;
QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
return;
}
if (mBlockSaveFlag)
return;
mBlockSaveFlag = true;
mCurrentSyncProfile = action - 1000 ;
mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
KSyncProfile* temp = new KSyncProfile ();
temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
temp->readConfig(&config);
KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
KOPrefs::instance()->mWriteBackInFuture = 0;
if ( temp->getWriteBackFuture() )
KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
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( KOPrefs::instance()->mEx2PhoneConnection );
+ ex2phone.mPhoneDevice->setText( KOPrefs::instance()->mEx2PhoneDevice );
+ ex2phone.mPhoneModel->setText( KOPrefs::instance()->mEx2PhoneModel );
+
+ if ( !ex2phone.exec() ) {
+ return;
+ }
+ KOPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
+ KOPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
+ KOPrefs::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( KOPrefs::instance()->mEx2PhoneDevice,
+ KOPrefs::instance()->mEx2PhoneConnection,
+ KOPrefs::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") );
}
void MainWindow::licence()
{
KApplication::showLicence();
}
void MainWindow::about()
{
QString version;
#include <../version>
QMessageBox::about( this, i18n("About KOrganizer/Pi"),
i18n("KOrganizer/Platform-independent\n") +
"(KO/Pi) " + version + " - " +
#ifdef DESKTOP_VERSION
i18n("Desktop Edition\n") +
#else
i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
#endif
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 7b24b88..74c7f45 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -51,159 +51,160 @@ private slots:
void send_file();
void get_file();
void end_connect();
QDialog* mSyncActionDialog;
QSocket* mSocket;
QString mPassWord;
QString mFileName;
QTime piTime;
QString piFileString;
};
class KCommandSocket : public QObject
{
Q_OBJECT
public:
enum state { successR, errorR, successW, errorW, quiet };
KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
void readFile( QString );
void writeFile( QString );
void sendStop();
signals:
void commandFinished( KCommandSocket*, int );
private slots:
void startReadFileFromSocket();
void readFileFromSocket();
void deleteSocket();
void writeFileToSocket();
private :
QSocket* mSocket;
QString mPassWord;
Q_UINT16 mPort;
QString mHost;
QString mFileName;
QTimer* mTimerSocket;
int mRetVal;
QTime mTime;
QString mFileString;
bool mFirst;
};
namespace KCal {
class CalendarLocal;
}
using namespace KCal;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
~MainWindow();
public slots:
virtual void showMaximized ();
void configureAgenda( int );
void recieve( const QCString& msg, const QByteArray& data );
static QString defaultFileName();
static QString syncFileName();
static QString resourcePath();
protected slots:
void setCaptionToDates();
int ringSync();
void multiSync( bool askforPrefs = false );
void about();
void licence();
void faq();
void usertrans();
void features();
void synchowto();
void whatsNew();
void keyBindings();
void aboutAutoSaving();;
void aboutKnownBugs();
void processIncidenceSelection( Incidence * );
void importQtopia();
void importBday();
void importOL();
void importIcal();
void importFile( QString, bool );
void quickImportIcal();
void slotModifiedChanged( bool );
void save();
void configureToolBar( int );
void printSel();
void printCal();
void saveCalendar();
void loadCalendar();
void exportVCalendar();
void fillFilterMenu();
void selectFilter( int );
+ void exportToPhone( int );
void slotSyncMenu( int );
void confSync();
void syncSharp();
void syncPhone();
void syncPi();
void syncLocalFile();
bool syncWithFile( QString, bool );
void quickSyncLocalFile();
protected:
void displayText( QString, QString);
void displayFile( QString, QString);
void enableIncidenceActions( bool );
private slots:
QSocket* piSocket;
QString piFileString;
QTime piTime;
void deleteCommandSocket(KCommandSocket* s, int state );
void fillSyncMenu();
void getFile( bool );
void readFileFromSocket();
private:
//QTimer* mTimerCommandSocket;
QString mPassWordPiSync;
KServerSocket * mServerSocket;
bool mClosed;
void saveOnClose();
int mCurrentSyncProfile;
void enableQuick();
void syncRemote( KSyncProfile* , bool ask = true);
bool mFlagKeyPressed;
bool mBlockAtStartup;
QPEToolBar *iconToolBar;
void initActions();
void setDefaultPreferences();
void keyPressEvent ( QKeyEvent * ) ;
void keyReleaseEvent ( QKeyEvent * ) ;
QPopupMenu *configureToolBarMenu;
QPopupMenu *selectFilterMenu;
QPopupMenu *configureAgendaMenu, *syncMenu;
CalendarLocal *mCalendar;
CalendarView *mView;
QString getPassword();
QAction *mNewSubTodoAction;
QAction *mShowAction;
QAction *mEditAction;
QAction *mDeleteAction;
void closeEvent( QCloseEvent* ce );
SimpleAlarmClient mAlarmClient;
QTimer mSaveTimer;
bool mBlockSaveFlag;
bool mCalendarModifiedFlag;
QPixmap loadPixmap( QString );
QDialog * mSyncActionDialog;
};
#endif
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 29c1ae6..b2a62b1 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,278 +1,286 @@
/*
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 "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 );
+}
+
+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();
}
-}
-PhoneFormat::~PhoneFormat()
-{
}
#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);
}
@@ -476,255 +484,263 @@ void PhoneFormat::copyEvent( Event* to, Event* from )
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 );
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;
+}
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;
-#ifdef _WIN32_
- QString fileName = locateLocal("tmp", "tempfile.vcs");
-#else
- QString fileName = "/tmp/kdepimtemp.vcs";
-#endif
// 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
- VCalFormat vfsave;
- vfsave.setLocalTime ( true );
- if ( ! vfsave.save( calendar, fileName ) )
+ if ( !writeToPhone( calendar ) )
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 sync"),i18n("Retry"),i18n("Cancel"));
- if ( retval != KMessageBox::Continue )
- 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();
procCount = 0;
QPtrList<Todo> tl1 = calendarTemp->rawTodos();
Todo* to1 ;
message = i18n(" Comparing todo # ");
while ( to ) {
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
uint csum;
csum = PhoneFormat::getCsumTodo( to );
QString cSum = QString::number( csum );
//to->setCsum( mProfileName, cSum );
//qDebug("Todo cSum %s ", cSum.latin1());
Todo* to1 = tl1.first();
while ( to1 ) {
if ( to1->getCsum( mProfileName ) == cSum ) {
tl1.remove( to1 );
afterSave( to );
to->setID(mProfileName, to1->getID(mProfileName) );
break;
}
to1 = tl1.next();
}
if ( ! to1 ) {
//to->removeID(mProfileName);
qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1());
}
to = tl.next();
}
delete calendarTemp;
return true;
}
QString PhoneFormat::toString( Calendar * )
{
return QString::null;
}
bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
{
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 2d1ff79..61e8160 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,61 +1,63 @@
/*
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