1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
/* This file is part of the libkmobile library.
Copyright (C) 2003 Helge Deller <deller@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 version 2 as published by the Free Software Foundation.
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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <qstring.h>
#include <qstringlist.h>
#include <klibloader.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <kio/global.h>
#include <kdebug.h>
#include <klocale.h>
#include "skeleton.h"
/* This is a loaded library, which is initialized with the line below */
K_EXPORT_COMPONENT_FACTORY( libkmobile_skeleton, KMobileSkeleton() )
/* createObject needs to be reimplemented by every KMobileDevice driver */
QObject *KMobileSkeleton::createObject( QObject *parent, const char *name,
const char *, const QStringList &args )
{
return new KMobileSkeleton( parent, name, args );
}
/**
* The KDE skeleton mobile device driver.
*/
KMobileSkeleton::KMobileSkeleton(QObject *obj, const char *name, const QStringList &args )
: KMobileDevice(obj, name, args)
{
// set initial device info
setClassType( Phone );
m_deviceName = i18n("LX-50-Moohoo Addressbook (Skeleton)");
m_deviceRevision = "0.1";
setCapabilities( hasAddressBook | hasNotes );
}
KMobileSkeleton::~KMobileSkeleton()
{
}
// connect the device and ask user to turn device on (if necessary)
bool KMobileSkeleton::connectDevice(QWidget *parent)
{
if (KMessageBox::Continue != KMessageBox::warningContinueCancel(parent,
i18n("Please turn on your %1 on now and press continue to proceed.").arg(m_deviceName),
m_deviceClassName ) )
return false;
// connect it now...
m_connected = true;
return m_connected;
}
// disconnect the device and return true, if sucessful
bool KMobileSkeleton::disconnectDevice(QWidget *)
{
m_connected = true;
return true;
}
// returns true, if this device is read-only (default: false)
bool KMobileSkeleton::isReadOnly() const
{
return true;
}
// return a unique ID, e.g. the IMEI number of phones, or a serial number
// this String is used to have a unique identification for syncronisation.
QString KMobileSkeleton::deviceUniqueID()
{
return QString::fromLocal8Bit("SkElEtOn-123456789");
}
QString KMobileSkeleton::iconFileName() const
{
return "mobile_unknown"; /* KMOBILE_ICON_UNKNOWN */
}
/*
* Addressbook / Phonebook support
*/
int KMobileSkeleton::numAddresses()
{
return 10; /* number of addresses we simulate */
}
int KMobileSkeleton::readAddress( int index, KABC::Addressee &addr )
{
// index is zero-based
if (index<0 || index>=numAddresses())
return KIO::ERR_DOES_NOT_EXIST;
// now build our own sample name
addr.setFamilyName(QString("Meyer_%1").arg(index+1));
addr.setGivenName("Peter");
addr.setFormattedName("Peter "+addr.familyName());
addr.setNickName("PeterM");
addr.setBirthday(QDateTime(QDate(1970,7,22)));
addr.setRole("KDE Software Developer");
addr.setOrganization("KDE.ORG");
addr.setNote("the best KDE developer ever");
addr.setUrl(KURL("www.kde.org"));
addr.insertEmail("peterm@kde.org");
addr.insertPhoneNumber(KABC::PhoneNumber("+49 6110 12345"));
// the Revision might be important for syncronisations
addr.setRevision(QDateTime(QDate(2003,1,1)));
return 0;
}
int KMobileSkeleton::storeAddress( int, const KABC::Addressee &, bool )
{
/* this is a read-only device */
return KIO::ERR_WRITE_ACCESS_DENIED;
}
/*
* Notes support
*/
int KMobileSkeleton::numNotes()
{
return 100;
}
int KMobileSkeleton::readNote( int index, QString ¬e )
{
// index is zero-based, and we only have one simulated note
if (index<0 || index>=numNotes())
return KIO::ERR_DOES_NOT_EXIST;
note = QString("NOTE #%1\n"
"--------\n"
"This is a sample note #%2\n\n"
"DeviceClassName: %3\n"
"Device Driver : %4\n"
"Device Revision: %5\n")
.arg(index).arg(index)
.arg(deviceClassName()).arg(deviceName()).arg(revision());
return 0;
}
#include "skeleton.moc"
|