41
41
#include <KComboBox>
42
42
#include <KMessageBox>
43
43
#include <KStandardDirs>
44
45
#include <KEditToolBar>
47
49
#include "lib/sflphone_const.h"
48
#include "lib/instance_interface_singleton.h"
49
#include "lib/configurationmanager_interface_singleton.h"
50
#include "lib/dbus/instancemanager.h"
51
#include "lib/dbus/configurationmanager.h"
50
52
#include "lib/contact.h"
51
#include "lib/accountlist.h"
53
#include "lib/accountlistmodel.h"
52
54
#include "lib/instantmessagingmodel.h"
55
#include "lib/numbercategorymodel.h"
56
#include "lib/visitors/numbercategoryvisitor.h"
53
57
#include "klib/macromodel.h"
58
#include "klib/akonadibackend.h"
59
#include "klib/kcfg_settings.h"
60
#include "lib/presencestatusmodel.h"
61
#include "lib/videomodel.h"
62
#include "lib/phonenumber.h"
56
#include "klib/akonadibackend.h"
57
65
#include "accountwizard.h"
58
66
#include "sflphoneview.h"
67
#include "actioncollection.h"
59
68
#include "widgets/sflphonetray.h"
60
69
#include "widgets/contactdock.h"
61
70
#include "widgets/historydock.h"
62
71
#include "widgets/bookmarkdock.h"
63
#include "widgets/videodock.h"
64
#include "klib/configurationskeleton.h"
72
#include "widgets/presence.h"
65
73
#include "sflphoneaccessibility.h"
66
#include "lib/videomodel.h"
67
74
#include "extendedaction.h"
68
75
#include "errormessage.h"
70
SFLPhone* SFLPhone::m_sApp = nullptr;
71
TreeWidgetCallModel* SFLPhone::m_pModel = nullptr;
77
#include "widgets/videodock.h"
80
SFLPhone* SFLPhone::m_sApp = nullptr;
82
class ConcreteNumberCategoryVisitor :public NumberCategoryVisitor {
83
void serialize(NumberCategoryModel* model)
87
for(int i=0;i<model->rowCount();i++) {
88
const QModelIndex& idx = model->index(i,0);
89
if (idx.data(Qt::CheckStateRole) == Qt::Checked) {
90
list << idx.data(NumberCategoryModel::Role::INDEX).toInt();
93
ConfigurationSkeleton::setPhoneTypeList(list);
96
void load(NumberCategoryModel* model)
99
QList<int> list = ConfigurationSkeleton::phoneTypeList();
100
const bool isEmpty = !list.size();
101
#define IS_ENABLED(name) (list.indexOf(name) != -1) || isEmpty
102
#define ICN(name) new QPixmap(KStandardDirs::locate("data" , QString("sflphone-client-kde/mini/%1.png").arg(name)))
103
model->addCategory("Home" ,ICN("home") , KABC::PhoneNumber::Home ,IS_ENABLED( KABC::PhoneNumber::Home ));
104
model->addCategory("Work" ,ICN("work") , KABC::PhoneNumber::Work ,IS_ENABLED( KABC::PhoneNumber::Work ));
105
model->addCategory("Msg" ,ICN("mail") , KABC::PhoneNumber::Msg ,IS_ENABLED( KABC::PhoneNumber::Msg ));
106
model->addCategory("Pref" ,ICN("call") , KABC::PhoneNumber::Pref ,IS_ENABLED( KABC::PhoneNumber::Pref ));
107
model->addCategory("Voice" ,ICN("video") , KABC::PhoneNumber::Voice,IS_ENABLED( KABC::PhoneNumber::Voice ));
108
model->addCategory("Fax" ,ICN("call") , KABC::PhoneNumber::Fax ,IS_ENABLED( KABC::PhoneNumber::Fax ));
109
model->addCategory("Cell" ,ICN("mobile") , KABC::PhoneNumber::Cell ,IS_ENABLED( KABC::PhoneNumber::Cell ));
110
model->addCategory("Video" ,ICN("call") , KABC::PhoneNumber::Video,IS_ENABLED( KABC::PhoneNumber::Video ));
111
model->addCategory("Bbs" ,ICN("call") , KABC::PhoneNumber::Bbs ,IS_ENABLED( KABC::PhoneNumber::Bbs ));
112
model->addCategory("Modem" ,ICN("call") , KABC::PhoneNumber::Modem,IS_ENABLED( KABC::PhoneNumber::Modem ));
113
model->addCategory("Car" ,ICN("car") , KABC::PhoneNumber::Car ,IS_ENABLED( KABC::PhoneNumber::Car ));
114
model->addCategory("Isdn" ,ICN("call") , KABC::PhoneNumber::Isdn ,IS_ENABLED( KABC::PhoneNumber::Isdn ));
115
model->addCategory("Pcs" ,ICN("call") , KABC::PhoneNumber::Pcs ,IS_ENABLED( KABC::PhoneNumber::Pcs ));
116
model->addCategory("Pager" ,ICN("pager") , KABC::PhoneNumber::Pager,IS_ENABLED( KABC::PhoneNumber::Pager ));
117
model->addCategory("Preferred",ICN("preferred"), 10000 ,IS_ENABLED( 10000 ));
122
// QVariant icon(QPixmap* icon )
124
// return QIcon(*icon);
74
129
SFLPhone::SFLPhone(QWidget *parent)
75
: KXmlGuiWindow(parent), m_pInitialized(false)
130
: KXmlGuiWindow(parent), m_pInitialized(false)
76
131
#ifdef ENABLE_VIDEO
77
132
,m_pVideoDW(nullptr)
80
if (!InstanceInterfaceSingleton::getInstance().connection().isConnected() || !InstanceInterfaceSingleton::getInstance().isValid()) {
81
QTimer::singleShot(5000,this,SLOT(timeout()));
135
if (!DBus::InstanceManager::instance().connection().isConnected() || !DBus::InstanceManager::instance().isValid()) {
136
QTimer::singleShot(5000,this,SLOT(timeout()));
138
static bool init = false;
140
Call::setContactBackend(AkonadiBackend::instance());
141
NumberCategoryModel::instance()->setVisitor(new ConcreteNumberCategoryVisitor());
142
InstantMessagingModelManager::init();
143
AccountListModel::instance()->setDefaultAccount(AccountListModel::instance()->getAccountById(ConfigurationSkeleton::defaultAccountId()));
145
VideoModel::instance();
84
//Belong to setupActions(), but is needed now
150
//Belong to setupActions(), but is needed now
86
action_accept = new ExtendedAction(this);
87
action_refuse = new ExtendedAction(this);
88
action_hold = new ExtendedAction(this);
89
action_transfer = new ExtendedAction(this);
90
action_record = new ExtendedAction(this);
91
action_mute = new ExtendedAction(this);
92
action_hangup = new ExtendedAction(this);
93
action_unhold = new ExtendedAction(this);
94
action_pickup = new ExtendedAction(this);
96
action_transfer->setAltIcon(KStandardDirs::locate("data" , "sflphone-client-kde/transfer_grayscale.png" ));
97
action_record ->setAltIcon(KStandardDirs::locate("data" , "sflphone-client-kde/record_grayscale.png" ));
98
action_hold ->setAltIcon(KStandardDirs::locate("data" , "sflphone-client-kde/hold_grayscale.png" ));
99
action_refuse ->setAltIcon(KStandardDirs::locate("data" , "sflphone-client-kde/refuse_grayscale.png" ));
100
action_mute ->setAltIcon(KStandardDirs::locate("data" , "sflphone-client-kde/mutemic_grayscale.png" ));
101
action_hangup ->setAltIcon(KStandardDirs::locate("data" , "sflphone-client-kde/hangup_grayscale.png" ));
102
action_unhold ->setAltIcon(KStandardDirs::locate("data" , "sflphone-client-kde/unhold_grayscale.png" ));
103
action_pickup ->setAltIcon(KStandardDirs::locate("data" , "sflphone-client-kde/pickup_grayscale.png" ));
105
action_transfer->setText ( i18n( "Transfer" ) );
106
action_record ->setText ( i18n( "Record" ) );
107
action_hold ->setText ( i18n( "Hold" ) );
108
action_refuse ->setText ( i18n( "Refuse" ) );
109
action_hangup ->setText ( i18n( "Hang up" ) );
110
action_unhold ->setText ( i18n( "Unhold" ) );
111
action_pickup ->setText ( i18n( "Pickup" ) );
112
action_mute ->setText ( i18nc("Mute the current audio device", "Mute" ) );
114
action_mute->setCheckable(true);
116
153
m_pView = new SFLPhoneView(this);
120
SFLPhone::~SFLPhone()
123
ConfigurationSkeleton::setDisplayContactDock ( m_pContactCD->isVisible() );
124
ConfigurationSkeleton::setDisplayHistoryDock ( m_pHistoryDW->isVisible() );
125
ConfigurationSkeleton::setDisplayBookmarkDock( m_pBookmarkDW->isVisible() );
128
delete action_accept ;
129
delete action_refuse ;
131
delete action_transfer ;
132
delete action_record ;
133
delete action_mailBox ;
134
delete action_close ;
136
delete action_displayVolumeControls ;
137
delete action_displayDialpad ;
138
delete action_displayMessageBox ;
139
delete action_configureSflPhone ;
140
delete action_configureShortcut ;
141
delete action_accountCreationWizard ;
142
delete action_pastenumber ;
143
delete action_showContactDock ;
144
delete action_showHistoryDock ;
145
delete action_showBookmarkDock ;
146
delete action_editToolBar ;
150
delete m_pStatusBarWidget ;
151
delete m_pContactCD ;
152
delete m_pCentralDW ;
153
delete m_pHistoryDW ;
154
delete m_pBookmarkDW ;
159
delete AkonadiBackend::getInstance();
160
TreeWidgetCallModel::destroy();
165
bool SFLPhone::initialize()
167
if ( m_pInitialized ) {
168
kDebug() << "Already initialized.";
172
155
ConfigurationSkeleton::self();
228
209
m_pCentralDW->show();
230
QList<QTabBar*> tabBars = this->findChildren<QTabBar*>();
233
foreach(QTabBar* bar, tabBars) {
234
for (int i=0;i<bar->count();i++) {
235
QString text = bar->tabText(i);
236
if (text == i18n("Call")) {
237
bar->setCurrentIndex(i);
244
213
setWindowIcon (QIcon(ICON_SFLPHONE) );
245
214
setWindowTitle(i18n("SFLphone") );
215
ActionCollection::instance()->setupAction();
216
setAutoSaveSettings();
248
m_pTrayIcon->addAction( action_accept );
249
m_pTrayIcon->addAction( action_mailBox );
250
m_pTrayIcon->addAction( action_refuse );
251
m_pTrayIcon->addAction( action_hold );
252
m_pTrayIcon->addAction( action_transfer );
253
m_pTrayIcon->addAction( action_record );
219
m_pTrayIcon->addAction( ActionCollection::instance()->acceptAction () );
220
m_pTrayIcon->addAction( ActionCollection::instance()->mailBoxAction () );
221
m_pTrayIcon->addAction( ActionCollection::instance()->refuseAction () );
222
m_pTrayIcon->addAction( ActionCollection::instance()->holdAction () );
223
m_pTrayIcon->addAction( ActionCollection::instance()->transferAction() );
224
m_pTrayIcon->addAction( ActionCollection::instance()->recordAction () );
254
225
m_pTrayIcon->addSeparator();
255
m_pTrayIcon->addAction( action_quit );
257
connect(action_showContactDock, SIGNAL(toggled(bool)),m_pContactCD, SLOT(setVisible(bool)));
258
connect(action_showHistoryDock, SIGNAL(toggled(bool)),m_pHistoryDW, SLOT(setVisible(bool)));
259
connect(action_showBookmarkDock,SIGNAL(toggled(bool)),m_pBookmarkDW,SLOT(setVisible(bool)));
262
connect(VideoModel::getInstance(),SIGNAL(videoCallInitiated(VideoRenderer*)),this,SLOT(displayVideoDock(VideoRenderer*)));
226
m_pTrayIcon->addAction( ActionCollection::instance()->quitAction () );
228
connect(ActionCollection::instance()->showContactDockAction(), SIGNAL(toggled(bool)),m_pContactCD, SLOT(setVisible(bool)));
229
connect(ActionCollection::instance()->showHistoryDockAction(), SIGNAL(toggled(bool)),m_pHistoryDW, SLOT(setVisible(bool)));
230
connect(ActionCollection::instance()->showBookmarkDockAction(),SIGNAL(toggled(bool)),m_pBookmarkDW,SLOT(setVisible(bool)));
233
connect(VideoModel::instance(),SIGNAL(videoCallInitiated(VideoRenderer*)),this,SLOT(displayVideoDock(VideoRenderer*)));
265
236
statusBar()->addWidget(m_pStatusBarWidget);
268
238
m_pTrayIcon->show();
271
240
setObjectNames();
272
241
QMetaObject::connectSlotsByName(this);
273
242
m_pView->loadWindow();
275
244
move(QCursor::pos().x() - geometry().width()/2, QCursor::pos().y() - geometry().height()/2);
278
if (AccountList::getInstance()->size() <= 1) {
246
if (AccountListModel::instance()->size() <= 1)
279
247
(new AccountWizard())->show();
282
m_pIconChanged = false;
283
249
m_pInitialized = true ;
285
251
KStatusBar* bar = statusBar();
287
QLabel* curAccL = new QLabel(i18n("Current account:"));
252
int left,top,right,bottom;
253
bar->layout()->getContentsMargins ( &left, &top, &right, &bottom );
254
bar->layout()->setContentsMargins(0,top,0,bottom);
256
//The presence button act as the label, remove the original one
257
QList<QLabel*> labels = bar->findChildren<QLabel*>();
258
for (int i=0;i<labels.size();i++) {
259
bar->layout()->removeWidget(labels[i]);
260
labels[i]->setHidden(true);
263
m_pPresent = new QToolButton(bar);
264
m_pPresent->setAutoRaise(true);
265
m_pPresent->setText("Online");
266
m_pPresent->setCheckable(true);
267
// m_pPresent->setStyleSheet("background-color:red;");
268
bar->addWidget(m_pPresent);
269
connect(PresenceStatusModel::instance(),SIGNAL(currentNameChanged(QString)),this,SLOT(updatePresence(QString)));
270
connect(PresenceStatusModel::instance(),SIGNAL(currentNameChanged(QString)),this,SLOT(hidePresenceDock()));
272
m_pPresenceDock = new QDockWidget(this);
273
m_pPresenceDock->setObjectName("presence-dock");
274
m_pPresenceDock->setWidget(new Presence(m_pPresenceDock));
275
m_pPresenceDock->setAllowedAreas(Qt::BottomDockWidgetArea);
276
m_pPresenceDock->setFeatures(QDockWidget::NoDockWidgetFeatures);
277
addDockWidget( Qt::BottomDockWidgetArea, m_pPresenceDock );
278
m_pPresenceDock->setVisible(false);
279
if (m_pPresenceDock->titleBarWidget())
280
m_pPresenceDock->titleBarWidget()->setVisible(false);
282
QLabel* curAccL = new QLabel(i18n("Account:"));
288
283
bar->addPermanentWidget(curAccL);
290
285
m_pAccountStatus = new KComboBox(bar);
291
AccountListNoCheckProxyModel* accountModel = new AccountListNoCheckProxyModel();
292
m_pAccountStatus->setModel(accountModel);
286
m_pAccountModel = new AccountListNoCheckProxyModel();
287
m_pAccountStatus->setModel(m_pAccountModel);
293
288
m_pAccountStatus->setMinimumSize(100,0);
294
289
bar->addPermanentWidget(m_pAccountStatus);
290
connect(m_pPresent,SIGNAL(toggled(bool)),m_pPresenceDock,SLOT(setVisible(bool)));
296
292
QToolButton* m_pReloadButton = new QToolButton(this);
297
293
m_pReloadButton->setIcon(KIcon("view-refresh"));
298
294
bar->addPermanentWidget(m_pReloadButton);
299
connect(m_pReloadButton,SIGNAL(clicked()),AccountList::getInstance(),SLOT(registerAllAccounts()));
295
connect(m_pReloadButton,SIGNAL(clicked()),AccountListModel::instance(),SLOT(registerAllAccounts()));
302
296
connect(m_pAccountStatus, SIGNAL(currentIndexChanged(int)), this, SLOT(currentAccountIndexChanged(int)) );
303
connect(AccountList::getInstance(), SIGNAL(priorAccountChanged(Account*)),this,SLOT(currentPriorAccountChanged(Account*)));
297
connect(AccountListModel::instance(), SIGNAL(priorAccountChanged(Account*)),this,SLOT(currentPriorAccountChanged(Account*)));
305
if (!model()->isValid()) {
299
if (!CallModel::instance()->isValid()) {
306
300
KMessageBox::error(this,i18n("The SFLPhone daemon (sflphoned) is not available. Please be sure it is installed correctly or launch it manually"));
307
301
QTimer::singleShot(2500,this,SLOT(timeout())); //FIXME this may leave the client in an unreliable state
308
302
//exit(1); //Don't try to exit normally, it will segfault, the application is already in a broken state if this is reached //BUG break some slow netbooks
311
currentPriorAccountChanged(AccountList::getCurrentAccount());
305
currentPriorAccountChanged(AccountListModel::currentAccount());
313
307
catch(const char * msg) {
314
308
KMessageBox::error(this,msg);
316
310
//exit(1); //Don't try to exit normally, it will segfault, the application is already in a broken state if this is reached //BUG break some slow netbooks
313
if (ConfigurationSkeleton::displayOnStart())
322
///Setup evry actions
323
void SFLPhone::setupActions()
320
SFLPhone::~SFLPhone()
325
kDebug() << "setupActions";
327
action_mailBox = new KAction(this);
328
action_accept->setShortcut ( Qt::CTRL + Qt::Key_A );
329
action_refuse->setShortcut ( Qt::CTRL + Qt::Key_D );
330
action_hold->setShortcut ( Qt::CTRL + Qt::Key_H );
331
action_transfer->setShortcut ( Qt::CTRL + Qt::Key_T );
332
action_record->setShortcut ( Qt::CTRL + Qt::Key_R );
333
action_mailBox->setShortcut ( Qt::CTRL + Qt::Key_M );
335
action_screen = new QActionGroup(this);
336
action_screen->setExclusive(true);
338
action_close = KStandardAction::close(this, SLOT(close()), this);
339
action_quit = KStandardAction::quit(this, SLOT(quitButton()), this);
341
action_configureSflPhone = KStandardAction::preferences(m_pView, SLOT(configureSflPhone()), this);
342
action_configureSflPhone->setText(i18n("Configure SFLphone"));
344
action_displayDialpad = new KAction(KIcon(QIcon(ICON_DISPLAY_DIALPAD)), i18n("Display dialpad") , this);
345
action_displayMessageBox = new KAction(KIcon("mail-message-new"), i18n("Display text message box") , this);
346
action_displayVolumeControls = new KAction(KIcon(QIcon(ICON_DISPLAY_VOLUME_CONSTROLS)), i18n("Display volume controls"), this);
347
action_pastenumber = new KAction(KIcon("edit-paste"), i18n("Paste") , this);
348
action_showContactDock = new KAction(KIcon("edit-find-user") , i18n("Display Contact") , this);
349
action_showHistoryDock = new KAction(KIcon("view-history") , i18n("Display history") , this);
350
action_showBookmarkDock = new KAction(KIcon("bookmark-new-list"), i18n("Display bookmark") , this);
351
action_editToolBar = new KAction(KIcon("configure-toolbars"), i18n("Configure Toolbars") , this);
352
action_accountCreationWizard = new KAction(i18n("Account creation wizard") , this);
354
action_displayDialpad->setCheckable( true );
355
action_displayDialpad->setChecked ( ConfigurationSkeleton::displayDialpad() );
356
action_configureSflPhone->setText(i18n("Configure SFLphone"));
358
action_displayMessageBox->setCheckable( true );
359
action_displayMessageBox->setChecked ( ConfigurationSkeleton::displayMessageBox() );
361
action_displayVolumeControls->setCheckable( true );
362
action_displayVolumeControls->setChecked ( ConfigurationSkeleton::displayVolume() );
364
action_pastenumber->setShortcut ( Qt::CTRL + Qt::Key_V );
366
action_showContactDock->setCheckable( true );
367
action_showContactDock->setChecked(ConfigurationSkeleton::displayContactDock());
369
action_showHistoryDock->setCheckable( true );
370
action_showHistoryDock->setChecked(ConfigurationSkeleton::displayHistoryDock());
372
action_showBookmarkDock->setCheckable( true );
373
action_showBookmarkDock->setChecked(ConfigurationSkeleton::displayBookmarkDock());
377
action_configureShortcut = new KAction(KIcon(KIcon("configure-shortcuts")), i18n("Configure Shortcut"), this);
378
// SENDER SIGNAL RECEIVER SLOT /
379
/**/connect(action_accept, SIGNAL(triggered()), m_pView , SLOT(accept()) );
380
/**/connect(action_hangup, SIGNAL(triggered()), m_pView , SLOT(hangup()) );
381
/**/connect(action_refuse, SIGNAL(triggered()), m_pView , SLOT(refuse()) );
382
/**/connect(action_hold, SIGNAL(triggered()), m_pView , SLOT(hold()) );
383
/**/connect(action_unhold, SIGNAL(triggered()), m_pView , SLOT(unhold()) );
384
/**/connect(action_transfer, SIGNAL(triggered()), m_pView , SLOT(transfer()) );
385
/**/connect(action_record, SIGNAL(triggered()), m_pView , SLOT(record()) );
386
/**/connect(action_mute, SIGNAL(toggled(bool)), m_pView , SLOT(mute(bool)) );
387
/**/connect(action_mailBox, SIGNAL(triggered()), m_pView , SLOT(mailBox()) );
388
/**/connect(action_displayVolumeControls, SIGNAL(toggled(bool)), m_pView , SLOT(displayVolumeControls(bool)) );
389
/**/connect(action_displayDialpad, SIGNAL(toggled(bool)), m_pView , SLOT(displayDialpad(bool)) );
390
/**/connect(action_displayMessageBox, SIGNAL(toggled(bool)), m_pView , SLOT(displayMessageBox(bool)) );
391
/**/connect(action_accountCreationWizard, SIGNAL(triggered()), m_pView , SLOT(accountCreationWizard()) );
392
/**/connect(action_pastenumber, SIGNAL(triggered()), m_pView , SLOT(paste()) );
393
/**/connect(action_configureShortcut, SIGNAL(triggered()), this , SLOT(showShortCutEditor()) );
394
/**/connect(action_editToolBar, SIGNAL(triggered()), this , SLOT(editToolBar()) );
395
/**/connect(MacroModel::getInstance(), SIGNAL(addAction(KAction*)), this , SLOT(addMacro(KAction*)) );
398
actionCollection()->addAction("action_accept" , action_accept );
399
actionCollection()->addAction("action_refuse" , action_refuse );
400
actionCollection()->addAction("action_hold" , action_hold );
401
actionCollection()->addAction("action_transfer" , action_transfer );
402
actionCollection()->addAction("action_record" , action_record );
403
actionCollection()->addAction("action_mailBox" , action_mailBox );
404
actionCollection()->addAction("action_close" , action_close );
405
actionCollection()->addAction("action_quit" , action_quit );
406
actionCollection()->addAction("action_displayVolumeControls" , action_displayVolumeControls );
407
actionCollection()->addAction("action_displayDialpad" , action_displayDialpad );
408
actionCollection()->addAction("action_displayMessageBox" , action_displayMessageBox );
409
actionCollection()->addAction("action_configureSflPhone" , action_configureSflPhone );
410
actionCollection()->addAction("action_accountCreationWizard" , action_accountCreationWizard );
411
actionCollection()->addAction("action_configureShortcut" , action_configureShortcut );
412
actionCollection()->addAction("action_pastenumber" , action_pastenumber );
413
actionCollection()->addAction("action_showContactDock" , action_showContactDock );
414
actionCollection()->addAction("action_showHistoryDock" , action_showHistoryDock );
415
actionCollection()->addAction("action_showBookmarkDock" , action_showBookmarkDock );
416
actionCollection()->addAction("action_editToolBar" , action_editToolBar );
418
MacroModel::getInstance()->initMacros();
421
QList<KAction*> acList = *SFLPhoneAccessibility::getInstance();
423
foreach(KAction* ac,acList) {
424
actionCollection()->addAction(ac->objectName() , ac);
323
ConfigurationSkeleton::setDisplayContactDock ( m_pContactCD->isVisible() );
324
ConfigurationSkeleton::setDisplayHistoryDock ( m_pHistoryDW->isVisible() );
325
ConfigurationSkeleton::setDisplayBookmarkDock( m_pBookmarkDW->isVisible() );
427
setAutoSaveSettings();
330
delete m_pStatusBarWidget ;
331
delete m_pContactCD ;
332
delete m_pCentralDW ;
333
delete m_pHistoryDW ;
334
delete m_pBookmarkDW ;
335
delete m_pAccountModel ;
337
delete m_pPresenceDock ;
339
delete AkonadiBackend::instance();
340
delete CallModel::instance();
345
bool SFLPhone::initialize() //TODO deprecate
347
return !m_pInitialized;
568
438
///Enable or disable toolbar items
569
439
void SFLPhone::on_m_pView_enabledActionsChangeAsked(const bool* enabledActions)
571
action_accept->setVisible ( enabledActions[SFLPhone::Accept ]);
572
action_refuse->setVisible ( enabledActions[SFLPhone::Refuse ]);
573
action_hold->setVisible ( enabledActions[SFLPhone::Hold ]);
574
action_transfer->setVisible ( enabledActions[SFLPhone::Transfer ]);
575
action_record->setVisible ( enabledActions[SFLPhone::Record ]);
576
action_mailBox->setVisible ( enabledActions[SFLPhone::Mailbox ]);
441
ActionCollection::instance()->acceptAction()->setVisible ( enabledActions[SFLPhone::CallAction::Accept ]);
442
ActionCollection::instance()->refuseAction()->setVisible ( enabledActions[SFLPhone::CallAction::Refuse ]);
443
ActionCollection::instance()->holdAction()->setVisible ( enabledActions[SFLPhone::CallAction::Hold ]);
444
ActionCollection::instance()->transferAction()->setVisible ( enabledActions[SFLPhone::CallAction::Transfer ]);
445
ActionCollection::instance()->recordAction()->setVisible ( enabledActions[SFLPhone::CallAction::Record ]);
446
ActionCollection::instance()->mailBoxAction()->setVisible ( enabledActions[SFLPhone::CallAction::Mailbox ]);
580
450
void SFLPhone::on_m_pView_actionIconsChangeAsked(const QString* actionIcons)
582
action_accept->setIcon ( QIcon(actionIcons[SFLPhone::Accept ]));
583
action_refuse->setIcon ( QIcon(actionIcons[SFLPhone::Refuse ]));
584
action_hold->setIcon ( QIcon(actionIcons[SFLPhone::Hold ]));
585
action_transfer->setIcon ( QIcon(actionIcons[SFLPhone::Transfer ]));
586
action_record->setIcon ( QIcon(actionIcons[SFLPhone::Record ]));
587
action_mailBox->setIcon ( QIcon(actionIcons[SFLPhone::Mailbox ]));
452
ActionCollection::instance()->acceptAction()->setIcon ( QIcon(actionIcons[SFLPhone::CallAction::Accept ]));
453
ActionCollection::instance()->refuseAction()->setIcon ( QIcon(actionIcons[SFLPhone::CallAction::Refuse ]));
454
ActionCollection::instance()->holdAction()->setIcon ( QIcon(actionIcons[SFLPhone::CallAction::Hold ]));
455
ActionCollection::instance()->transferAction()->setIcon ( QIcon(actionIcons[SFLPhone::CallAction::Transfer ]));
456
ActionCollection::instance()->recordAction()->setIcon ( QIcon(actionIcons[SFLPhone::CallAction::Record ]));
457
ActionCollection::instance()->mailBoxAction()->setIcon ( QIcon(actionIcons[SFLPhone::CallAction::Mailbox ]));
591
461
void SFLPhone::on_m_pView_actionTextsChangeAsked(const QString* actionTexts)
593
action_accept->setText ( actionTexts[SFLPhone::Accept ]);
594
action_refuse->setText ( actionTexts[SFLPhone::Refuse ]);
595
action_hold->setText ( actionTexts[SFLPhone::Hold ]);
596
action_transfer->setText ( actionTexts[SFLPhone::Transfer ]);
597
action_record->setText ( actionTexts[SFLPhone::Record ]);
598
action_mailBox->setText ( actionTexts[SFLPhone::Mailbox ]);
463
ActionCollection::instance()->acceptAction()->setText ( actionTexts[SFLPhone::CallAction::Accept ]);
464
ActionCollection::instance()->refuseAction()->setText ( actionTexts[SFLPhone::CallAction::Refuse ]);
465
ActionCollection::instance()->holdAction()->setText ( actionTexts[SFLPhone::CallAction::Hold ]);
466
ActionCollection::instance()->transferAction()->setText ( actionTexts[SFLPhone::CallAction::Transfer ]);
467
ActionCollection::instance()->recordAction()->setText ( actionTexts[SFLPhone::CallAction::Record ]);
468
ActionCollection::instance()->mailBoxAction()->setText ( actionTexts[SFLPhone::CallAction::Mailbox ]);
601
471
///Change transfer state
602
472
void SFLPhone::on_m_pView_transferCheckStateChangeAsked(bool transferCheckState)
604
action_transfer->setChecked(transferCheckState);
474
ActionCollection::instance()->transferAction()->setChecked(transferCheckState);
607
477
///Change record state
608
478
void SFLPhone::on_m_pView_recordCheckStateChangeAsked(bool recordCheckState)
610
action_record->setChecked(recordCheckState);
480
ActionCollection::instance()->recordAction()->setChecked(recordCheckState);
613
483
///Called when a call is coming
614
484
void SFLPhone::on_m_pView_incomingCall(const Call* call)
616
Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(call->getPeerPhoneNumber());
617
if (contact && call) {
618
KNotification::event(KNotification::Notification, i18n("New incoming call"), i18n("New call from:\n%1",call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName()),((contact->getPhoto())?*contact->getPhoto():nullptr));
487
const Contact* contact = call->peerPhoneNumber()->contact();
489
KNotification::event(KNotification::Notification, i18n("New incoming call"), i18n("New call from:\n%1",call->peerName().isEmpty() ? call->peerPhoneNumber()->uri() : call->peerName()),((contact->photo())?*contact->photo():nullptr));
491
KNotification::event(KNotification::Notification, i18n("New incoming call"), i18n("New call from:\n%1",call->peerName().isEmpty() ? call->peerPhoneNumber()->uri() : call->peerName()));
620
KNotification::event(KNotification::Notification, i18n("New incoming call"), i18n("New call from:\n%1",call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName()));
623
495
///Change current account
624
496
void SFLPhone::currentAccountIndexChanged(int newIndex)
626
if (AccountList::getInstance()->size()) {
627
Account* acc = AccountList::getInstance()->getAccountByModelIndex(AccountList::getInstance()->index(newIndex,0));
498
if (AccountListModel::instance()->size()) {
499
const Account* acc = AccountListModel::instance()->getAccountByModelIndex(AccountListModel::instance()->index(newIndex,0));
629
AccountList::getInstance()->setPriorAccount(acc);
501
AccountListModel::instance()->setPriorAccount(acc);
633
505
///Update the combobox index
634
506
void SFLPhone::currentPriorAccountChanged(Account* newPrior)
636
if (InstanceInterfaceSingleton::getInstance().connection().isConnected() && newPrior) {
637
m_pAccountStatus->setCurrentIndex(newPrior->getIndex().row());
508
if (DBus::InstanceManager::instance().connection().isConnected() && newPrior) {
509
m_pAccountStatus->setCurrentIndex(newPrior->index().row());
640
512
kDebug() << "Daemon not responding";