~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to solid/modemmanager-0.4/modemgsmcontactsinterface.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright 2008 Will Stephenson <wstephenson@kde.org>
 
3
Copyright 2010 Lamarque Souza <lamarque@gmail.com>
 
4
 
 
5
This program is free software; you can redistribute it and/or
 
6
modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of
 
7
the License or (at your option) version 3 or any later version
 
8
accepted by the membership of KDE e.V. (or its successor approved
 
9
by the membership of KDE e.V.), which shall act as a proxy
 
10
defined in Section 14 of version 3 of the license.
 
11
 
 
12
This program is distributed in the hope that it will be useful,
 
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
GNU General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU General Public License
 
18
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*/
 
20
 
 
21
#include "manager.h"
 
22
#include "modemgsmcontactsinterface.h"
 
23
#include "modemgsmcontactsinterface_p.h"
 
24
 
 
25
#include <KDebug>
 
26
 
 
27
MMModemGsmContactsInterfacePrivate::MMModemGsmContactsInterfacePrivate(const QString &path, QObject *owner)
 
28
    : MMModemInterfacePrivate(path, owner), modemGsmContactsIface(MMModemManager::DBUS_SERVICE, path, QDBusConnection::systemBus())
 
29
{
 
30
}
 
31
 
 
32
MMModemGsmContactsInterface::MMModemGsmContactsInterface(const QString & path, MMModemManager * manager, QObject * parent)
 
33
    : MMModemInterface(*new MMModemGsmContactsInterfacePrivate(path, this), manager, parent)
 
34
{
 
35
}
 
36
 
 
37
MMModemGsmContactsInterface::~MMModemGsmContactsInterface()
 
38
{
 
39
}
 
40
 
 
41
int MMModemGsmContactsInterface::addContact(const QString & name, const QString & number)
 
42
{
 
43
    Q_D(MMModemGsmContactsInterface);
 
44
    QDBusReply<uint> index = d->modemGsmContactsIface.Add(name, number);
 
45
 
 
46
    if (index.isValid()) {
 
47
        return index.value();
 
48
    }
 
49
    return -1;
 
50
}
 
51
 
 
52
void MMModemGsmContactsInterface::deleteContact(const int index)
 
53
{
 
54
    Q_D(MMModemGsmContactsInterface);
 
55
    d->modemGsmContactsIface.Delete(index);
 
56
}
 
57
 
 
58
ContactType MMModemGsmContactsInterface::get(const int index)
 
59
{
 
60
    Q_D(MMModemGsmContactsInterface);
 
61
    QDBusReply<ContactType> contact = d->modemGsmContactsIface.Get(index);
 
62
 
 
63
    if (contact.isValid()) {
 
64
        return contact.value();
 
65
    }
 
66
 
 
67
    return ContactType();
 
68
}
 
69
 
 
70
Solid::Control::ModemGsmContactsInterface::ContactTypeList MMModemGsmContactsInterface::list()
 
71
{
 
72
    Q_D(MMModemGsmContactsInterface);
 
73
    QDBusReply<ContactTypeList> contacts = d->modemGsmContactsIface.List();
 
74
 
 
75
    if (contacts.isValid()) {
 
76
        return contacts.value();
 
77
    }
 
78
 
 
79
    return ContactTypeList();
 
80
}
 
81
 
 
82
Solid::Control::ModemGsmContactsInterface::ContactTypeList MMModemGsmContactsInterface::find(const QString & pattern)
 
83
{
 
84
    Q_D(MMModemGsmContactsInterface);
 
85
    QDBusReply<ContactTypeList > contacts = d->modemGsmContactsIface.Find(pattern);
 
86
 
 
87
    if (contacts.isValid()) {
 
88
        return contacts.value();
 
89
    }
 
90
 
 
91
    return ContactTypeList();
 
92
}
 
93
 
 
94
int MMModemGsmContactsInterface::getCount()
 
95
{
 
96
    Q_D(MMModemGsmContactsInterface);
 
97
    QDBusReply<uint> count = d->modemGsmContactsIface.GetCount();
 
98
 
 
99
    if (count.isValid()) {
 
100
        return count.value();
 
101
    }
 
102
 
 
103
    return 0;
 
104
}
 
105
 
 
106
#include "modemgsmcontactsinterface.moc"
 
107