~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to kde/src/klib/macro.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 *   Copyright (C) 2013-2014 by Savoir-Faire Linux                          *
 
3
 *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
 
4
 *                                                                          *
 
5
 *   This library is free software; you can redistribute it and/or          *
 
6
 *   modify it under the terms of the GNU Lesser General Public             *
 
7
 *   License as published by the Free Software Foundation; either           *
 
8
 *   version 2.1 of the License, or (at your option) any later version.     *
 
9
 *                                                                          *
 
10
 *   This library is distributed in the hope that it will be useful,        *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
 
13
 *   Lesser General Public License for more details.                        *
 
14
 *                                                                          *
 
15
 *   You should have received a copy of the GNU General Public License      *
 
16
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 
17
 ***************************************************************************/
 
18
#include "macro.h"
 
19
 
 
20
//Qt
 
21
#include <QtCore/QTimer>
 
22
 
 
23
//KDE
 
24
#include <KAction>
 
25
#include <KLocale>
 
26
#include <KIcon>
 
27
 
 
28
//SFLPhone
 
29
#include "../lib/dbus/callmanager.h"
 
30
 
 
31
Macro::Macro(QObject* parent) : QObject(parent),m_Position(0),m_Delay(0),m_pCat(nullptr),m_pPointer(nullptr),
 
32
m_Action(nullptr),m_pModel(nullptr)
 
33
{
 
34
}
 
35
 
 
36
Macro::Macro(const Macro* macro) : 
 
37
QObject(0)                         , m_Position(macro->m_Position), m_Name(macro->m_Name)        ,
 
38
m_Description(macro->m_Description), m_Sequence(macro->m_Sequence), m_Escaped(macro->m_Escaped)  ,
 
39
m_Id(macro->m_Id)                  , m_Delay(macro->m_Delay)      , m_Category(macro->m_Category),
 
40
m_Action(macro->m_Action)          , m_pCat(macro->m_pCat)        , m_pModel(macro->m_pModel)    ,
 
41
m_pPointer(macro->m_pPointer)
 
42
{}
 
43
 
 
44
void Macro::execute() {
 
45
   m_Escaped = m_Sequence;
 
46
   while (m_Escaped.indexOf("\\n") != -1) {
 
47
      m_Escaped = m_Escaped.replace("\\n","\n");
 
48
   }
 
49
   nextStep();
 
50
}
 
51
 
 
52
void Macro::nextStep()
 
53
{
 
54
   if (m_Position < m_Escaped.size()) {
 
55
      if (!MacroModel::instance()->m_lListeners.size())
 
56
         Q_NOREPLY DBus::CallManager::instance().playDTMF(QString(m_Escaped[m_Position]));
 
57
      else {
 
58
         foreach(MacroListener* l,MacroModel::instance()->m_lListeners) {
 
59
            l->addDTMF(QString(m_Escaped[m_Position]));
 
60
         }
 
61
      }
 
62
      m_Position++;
 
63
      QTimer::singleShot(m_Delay?m_Delay:100,this,SLOT(nextStep()));
 
64
   }
 
65
   else {
 
66
      m_Position = 0;
 
67
   }
 
68
}
 
69
 
 
70
QModelIndex Macro::index()
 
71
{
 
72
   QModelIndex parent = m_pModel->index(m_pModel->m_lCategories.indexOf(m_pCat),0,QModelIndex());
 
73
   return  m_pModel->index(m_pCat->m_lContent.indexOf(this),0,parent);
 
74
}
 
75
 
 
76
void Macro::setName(const QString &value)
 
77
{
 
78
   m_Name = value;
 
79
   emit changed(this);
 
80
   m_Action->setText(m_Name);
 
81
}
 
82
 
 
83
void Macro::setDescription(const QString &value)
 
84
{
 
85
   m_Description = value;emit changed(this);
 
86
}
 
87
void Macro::setSequence(const QString &value)
 
88
{
 
89
   m_Sequence = value;emit changed(this);
 
90
}
 
91
 
 
92
void Macro::setEscaped(const QString &value)
 
93
{
 
94
   m_Escaped = value;emit changed(this);
 
95
}
 
96
 
 
97
void Macro::setId(const QString &value)
 
98
{
 
99
   m_Id = value;emit changed(this);
 
100
}
 
101
 
 
102
void Macro::setDelay(int value)
 
103
{
 
104
   m_Delay = value;emit changed(this);
 
105
}
 
106
 
 
107
void Macro::setCategory(const QString &value)
 
108
{
 
109
   m_Category = value;emit changed(this);
 
110
}
 
111
 
 
112
QString Macro::name() const
 
113
{
 
114
   return m_Name;
 
115
}
 
116
 
 
117
QString Macro::description() const
 
118
{
 
119
   return m_Description;
 
120
}
 
121
 
 
122
QString Macro::sequence() const
 
123
{
 
124
   return m_Sequence;
 
125
}
 
126
 
 
127
QString Macro::escaped() const
 
128
{
 
129
   return m_Escaped;
 
130
}
 
131
 
 
132
QString Macro::id() const
 
133
{
 
134
   return m_Id;
 
135
}
 
136
 
 
137
int Macro::delay() const
 
138
{
 
139
   return m_Delay;
 
140
}
 
141
 
 
142
QString  Macro::category() const
 
143
{
 
144
   return m_Category;
 
145
}
 
146
 
 
147
KAction* Macro::action()
 
148
{
 
149
   return m_Action;
 
150
}