~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to kde/plasma/dataengine/sflphonEngine.cpp

  • Committer: Package Import Robot
  • Author(s): Francois Marier
  • Date: 2012-02-18 21:47:09 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120218214709-6362d71gqdsdkrj5
Tags: 1.0.2-1
* New upstream release
  - remove logging patch (applied upstream)
  - update s390 patch since it was partially applied upstream
* Include the Evolution plugin as a separate binary package

* Fix compilation issues on SH4 (closes: #658987)
* Merge Ubuntu's binutils-gold linking fix

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "sflphonEngine.h"
 
2
 
 
3
#include <Plasma/DataContainer>
 
4
 
 
5
#include "../../src/lib/Call.h"
 
6
#include "../../src/lib/dbus/metatypes.h"
 
7
#include "../../src/lib/instance_interface_singleton.h"
 
8
#include "../../src/lib/configurationmanager_interface_singleton.h"
 
9
#include "../../src/lib/callmanager_interface_singleton.h"
 
10
#include "../../src/lib/sflphone_const.h"
 
11
 
 
12
SFLPhoneEngine::SFLPhoneEngine(QObject* parent, const QVariantList& args)
 
13
    : Plasma::DataEngine(parent, args)
 
14
{
 
15
   Q_UNUSED(args)
 
16
   m_pModel = new CallModelConvenience(CallModelConvenience::ActiveCall);
 
17
   m_pModel->initCall();
 
18
   m_pModel->initHistory();
 
19
 
 
20
   CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
 
21
 
 
22
   connect(m_pModel              , SIGNAL( callStateChanged(Call*))  , this , SLOT(callStateChangedSignal(Call*)  ));
 
23
   connect(&callManager          , SIGNAL( incomingCall(Call*))      , this , SLOT(incomingCallSignal(Call*)      ));
 
24
   connect(&callManager          , SIGNAL( conferenceCreated(Call*)) , this , SLOT(conferenceCreatedSignal(Call*) ));
 
25
   connect(&callManager          , SIGNAL( conferenceChanged(Call*)) , this , SLOT(conferenceChangedSignal(Call*) ));
 
26
}
 
27
 
 
28
bool SFLPhoneEngine::sourceRequestEvent(const QString &name)
 
29
{
 
30
   if      ( name == "history"     ) {
 
31
      updateHistory();
 
32
   }
 
33
   else if ( name == "calls"       ) {
 
34
      updateCallList();
 
35
   }
 
36
   else if ( name == "conferences" ) {
 
37
      updateConferenceList();
 
38
   }
 
39
   else if ( name == "info"        ) {
 
40
      updateInfo();
 
41
   }
 
42
   return true;//updateSourceEvent(name);
 
43
}
 
44
 
 
45
bool SFLPhoneEngine::updateSourceEvent(const QString &name)
 
46
{
 
47
   Q_UNUSED(name)
 
48
   return true;
 
49
}
 
50
 
 
51
QStringList SFLPhoneEngine::sources() const {
 
52
   QStringList toReturn;
 
53
   toReturn << "calls" << "history" << "conferences" << "info";
 
54
   return toReturn;
 
55
}
 
56
 
 
57
QString SFLPhoneEngine::getCallStateName(call_state state)
 
58
{
 
59
   if (state == CALL_STATE_INCOMING) {
 
60
      return I18N_NOOP("Ringing (in)");
 
61
   } else if (state == CALL_STATE_RINGING) {
 
62
      return I18N_NOOP("Ringing (out)");
 
63
   } else if (state == CALL_STATE_CURRENT) {
 
64
      return I18N_NOOP("Talking");
 
65
   } else if (state == CALL_STATE_DIALING) {
 
66
      return I18N_NOOP("Dialing");
 
67
   } else if (state == CALL_STATE_HOLD) {
 
68
      return I18N_NOOP("Hold");
 
69
   } else if (state == CALL_STATE_FAILURE) {
 
70
      return I18N_NOOP("Failed");
 
71
   } else if (state == CALL_STATE_BUSY) {
 
72
      return I18N_NOOP("Busy");
 
73
   } else if (state == CALL_STATE_TRANSFER) {
 
74
      return I18N_NOOP("Transfer");
 
75
   } else if (state == CALL_STATE_TRANSF_HOLD) {
 
76
      return I18N_NOOP("Transfer hold");
 
77
   } else if (state == CALL_STATE_OVER) {
 
78
      return I18N_NOOP("Over");
 
79
   } else if (state == CALL_STATE_ERROR) {
 
80
      return I18N_NOOP("Error");
 
81
   }
 
82
   return "";
 
83
}
 
84
 
 
85
void SFLPhoneEngine::updateHistory()
 
86
{
 
87
   foreach (Call* oldCall, m_pModel->getHistory()) {
 
88
      historyCall[oldCall->getCallId()][ "Name"   ] = oldCall->getPeerName();
 
89
      historyCall[oldCall->getCallId()][ "Number" ] = oldCall->getPeerPhoneNumber();
 
90
      historyCall[oldCall->getCallId()][ "Date"   ] = oldCall->getStopTimeStamp();
 
91
      setData("history", I18N_NOOP(oldCall->getCallId()), historyCall[oldCall->getCallId()]);
 
92
   }
 
93
}
 
94
 
 
95
void SFLPhoneEngine::updateCallList()
 
96
{
 
97
   foreach (Call* call, m_pModel->getCalls()) {
 
98
      if ((!m_pModel->isConference(call)) && (call->getState() != CALL_STATE_OVER)) {
 
99
         currentCall[call->getCallId()][ "Name"      ] = call->getPeerName();
 
100
         currentCall[call->getCallId()][ "Number"    ] = call->getPeerPhoneNumber();
 
101
         currentCall[call->getCallId()][ "StateName" ] = getCallStateName(call->getState());
 
102
         currentCall[call->getCallId()][ "State"     ] = call->getState();
 
103
         setData("calls", call->getCallId(), currentCall[call->getCallId()]);
 
104
      }
 
105
   }
 
106
}
 
107
 
 
108
void SFLPhoneEngine::updateConferenceList()
 
109
{
 
110
   foreach (Call* call, m_pModel->getCalls()) {
 
111
      if (m_pModel->isConference(call)) {
 
112
         CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
 
113
         currentConferences[call->getConfId()] = callManager.getParticipantList(call->getConfId());
 
114
         setData("conferences", call->getConfId(), currentConferences[call->getConfId()]);
 
115
      }
 
116
   }
 
117
}
 
118
 
 
119
void SFLPhoneEngine::updateContacts()
 
120
{
 
121
 
 
122
}
 
123
 
 
124
void SFLPhoneEngine::updateInfo()
 
125
{
 
126
   qDebug() << "Currentaccount: " << m_pModel->getCurrentAccountId();
 
127
   setData("info", I18N_NOOP("Account"), m_pModel->getCurrentAccountId());
 
128
}
 
129
 
 
130
void SFLPhoneEngine::callStateChangedSignal(Call* call)
 
131
{
 
132
   Q_UNUSED(call)
 
133
   updateCallList();
 
134
}
 
135
 
 
136
void SFLPhoneEngine::incomingCallSignal(Call* call)
 
137
{
 
138
   Q_UNUSED(call)
 
139
   updateCallList();
 
140
}
 
141
 
 
142
void SFLPhoneEngine::conferenceCreatedSignal(Call* conf)
 
143
{
 
144
   Q_UNUSED(conf)
 
145
   updateConferenceList();
 
146
}
 
147
 
 
148
void SFLPhoneEngine::conferenceChangedSignal(Call* conf)
 
149
{
 
150
   Q_UNUSED(conf)
 
151
   updateConferenceList();
 
152
}
 
153
 
 
154
void SFLPhoneEngine::incomingMessageSignal(const QString& accountId, const QString& message)
 
155
{
 
156
   Q_UNUSED(accountId)
 
157
   Q_UNUSED(message)
 
158
   //TODO
 
159
}
 
160
 
 
161
void SFLPhoneEngine::voiceMailNotifySignal(const QString& accountId, int count)
 
162
{
 
163
   Q_UNUSED(accountId)
 
164
   Q_UNUSED(count)
 
165
   //TODO
 
166
}
 
167
 
 
168
void SFLPhoneEngine::accountChanged()
 
169
{
 
170
 
 
171
}
 
172
 
 
173
K_EXPORT_PLASMA_DATAENGINE(sflphone, SFLPhoneEngine)