summaryrefslogtreecommitdiffabout
path: root/libkdepim
Side-by-side diff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kpimglobalprefs.cpp7
-rw-r--r--libkdepim/kpimglobalprefs.h3
-rw-r--r--libkdepim/libkdepim.pro6
-rw-r--r--libkdepim/libkdepimE.pro6
-rw-r--r--libkdepim/phoneaccess.cpp153
-rw-r--r--libkdepim/phoneaccess.h42
6 files changed, 213 insertions, 4 deletions
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index b2b7663..b71e18d 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -96,12 +96,19 @@ KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
addItemInt( "SIPChannelType", &mSipClient, NONE_SIC );
addItemString( "SIPChannel", &mSipOtherChannel, "" );
addItemString( "SIPChannelMessage", &mSipOtherMessage, "" );
addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" );
+
+ KPrefs::setCurrentGroup( "PhoneAccess" );
+ addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm");
+ addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda");
+ addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i");
+
+
}
void KPimGlobalPrefs::setGlobalConfig()
{
KGlobal::locale()->setHore24Format( !mPreferredTime );
diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h
index 84ba689..f6b6628 100644
--- a/libkdepim/kpimglobalprefs.h
+++ b/libkdepim/kpimglobalprefs.h
@@ -126,10 +126,13 @@ class KPimGlobalPrefs : public KPrefs
int mSipClient;
QString mSipOtherChannel;
QString mSipOtherMessage;
QString mSipOtherMessageParameters;
+ QString mEx2PhoneDevice;
+ QString mEx2PhoneConnection;
+ QString mEx2PhoneModel;
};
#endif
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index eac19ea..84af7ad 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -32,13 +32,14 @@ HEADERS = \
kprefsdialog.h \
kprefswidget.h \
ksyncmanager.h \
ksyncprofile.h \
ksyncprefsdialog.h \
kcmconfigs/kcmkdepimconfig.h \
- kcmconfigs/kdepimconfigwidget.h
+ kcmconfigs/kdepimconfigwidget.h \
+ phoneaccess.h
SOURCES = \
categoryeditdialog.cpp \
categoryeditdialog_base.cpp \
categoryselectdialog.cpp \
categoryselectdialog_base.cpp \
@@ -51,9 +52,10 @@ SOURCES = \
kprefsdialog.cpp \
kprefswidget.cpp \
ksyncmanager.cpp \
ksyncprofile.cpp \
ksyncprefsdialog.cpp \
kcmconfigs/kcmkdepimconfig.cpp \
- kcmconfigs/kdepimconfigwidget.cpp
+ kcmconfigs/kdepimconfigwidget.cpp \
+ phoneaccess.cpp
diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro
index 156e247..f3db68e 100644
--- a/libkdepim/libkdepimE.pro
+++ b/libkdepim/libkdepimE.pro
@@ -26,13 +26,14 @@ HEADERS = \
kprefsdialog.h \
kprefswidget.h \
ksyncmanager.h \
ksyncprofile.h \
ksyncprefsdialog.h \
kcmconfigs/kcmkdepimconfig.h \
- kcmconfigs/kdepimconfigwidget.h
+ kcmconfigs/kdepimconfigwidget.h \
+ phoneaccess.h
SOURCES = \
categoryeditdialog.cpp \
categoryeditdialog_base.cpp \
@@ -47,9 +48,10 @@ SOURCES = \
kprefsdialog.cpp \
kprefswidget.cpp \
ksyncmanager.cpp \
ksyncprofile.cpp \
ksyncprefsdialog.cpp \
kcmconfigs/kcmkdepimconfig.cpp \
- kcmconfigs/kdepimconfigwidget.cpp
+ kcmconfigs/kdepimconfigwidget.cpp \
+ phoneaccess.cpp
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp
new file mode 100644
index 0000000..c0bd6cc
--- a/dev/null
+++ b/libkdepim/phoneaccess.cpp
@@ -0,0 +1,153 @@
+/*
+ This file is part of libkdepim.
+
+ 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 <qstring.h>
+#include <qapplication.h>
+#include <qptrlist.h>
+#include <qregexp.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qtextcodec.h>
+#include <qdir.h>
+#include <kmessagebox.h>
+#include <stdlib.h>
+#include "phoneaccess.h"
+
+void PhoneAccess::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();
+ }
+
+}
+
+
+bool PhoneAccess::writeToPhone( QString fileName)
+{
+
+#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;
+}
diff --git a/libkdepim/phoneaccess.h b/libkdepim/phoneaccess.h
new file mode 100644
index 0000000..b7c4732
--- a/dev/null
+++ b/libkdepim/phoneaccess.h
@@ -0,0 +1,42 @@
+/*
+ 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 PHONEACCESS_H
+#define PHONEACCESS_H
+
+#include <qstring.h>
+
+
+
+/**
+ This class implements the calendar format used by Phone.
+*/
+
+class PhoneAccess : public QObject {
+ public:
+
+ static void writeConfig( QString device,QString connection, QString model );
+ static bool writeToPhone( QString fileName );
+
+};
+
+
+
+#endif