[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/pim/kcall/kcall
From:       Tobias Hunger <tobias.hunger () basyskom ! de>
Date:       2007-07-29 16:51:34
Message-ID: 1185727894.909028.31865.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 693963 by hunger:

* Disable Kontact plugin: The kontact developers claim the required
  API are to be considered private at this time.

* Add DTMF input widget and wire it up.

TODO: Fix action to make the DTMF input widget show.


 M  +6 -2      CMakeLists.txt  
 M  +64 -0     callmodel.cpp  
 M  +2 -0      callmodel.h  
 A             dtmfinput.cpp   [License: LGPL (v2.1+)]
 A             dtmfinput.h   [License: LGPL (v2.1)]
 A             dtmfinput.ui  
 M  +50 -51    kcallcore.cpp  
 M  +7 -3      kcallcore.h  
 M  +4 -0      kcallview.cpp  
 M  +6 -4      kcallview.h  


--- trunk/playground/pim/kcall/kcall/CMakeLists.txt #693962:693963
@@ -36,6 +36,7 @@
     keypad.cpp 
     historymodel.cpp
     callmodel.cpp
+    dtmfinput.cpp
 )
 
 QT4_ADD_DBUS_INTERFACE(kcall_LIB_SRCS
@@ -52,7 +53,7 @@
 KDE4_ADD_KCFG_FILES(kcall_LIB_SRCS kcallsettings.kcfgc)
 
 KDE4_ADD_UI_FILES(kcall_LIB_SRCS
-                  keypad.ui kcallview.ui vcardview.ui
+                  keypad.ui kcallview.ui vcardview.ui dtmfinput.ui
 )
 
 KDE4_ADD_LIBRARY(kcall SHARED ${kcall_LIB_SRCS} ${kcallcore_DBUS_IFACE})
@@ -125,5 +126,8 @@
 
 #############
 
-ADD_SUBDIRECTORY(kontactplugin)
+## Kontact developers say they do not want kontact plugins
+## from outside KDEPIM: The interfaces are not stable
+## and will change without notice.
+# ADD_SUBDIRECTORY(kontactplugin)
 
--- trunk/playground/pim/kcall/kcall/callmodel.cpp #693962:693963
@@ -399,3 +399,67 @@
         break;
     }
 }
+
+bool CallModel::hasDTMFSupport(const QString & id)
+{
+    qDebug() << "CallModel::hasDTMFSupport";
+    int pos = d->findChannelInfo(id);
+    if (-1 == pos) { return false; }
+
+    CallModelPrivate::ChannelInfo * info(&(d->m_channels[pos]));
+    Q_ASSERT(0 != info->channel);
+
+    return info->channel->hasDTMFSupport();
+}
+
+void CallModel::sendDTMF(const QString & id, const QChar tone)
+{
+    qDebug() << "CallModel::sendDTMF";
+    int pos = d->findChannelInfo(id);
+    if (-1 == pos) { return; }
+
+    CallModelPrivate::ChannelInfo * info(&(d->m_channels[pos]));
+    Q_ASSERT(0 != info->channel);
+
+    QModelIndex idx(index(pos, int(STATUS)));
+    switch (info->status)
+    {
+    case ACTIVE:
+        if (info->channel->hasDTMFSupport())
+        {
+            uchar event;
+            if (tone == '0')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Digit_0; }
+            else if (tone == '1')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Digit_1; }
+            else if (tone == '2')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Digit_2; }
+            else if (tone == '3')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Digit_3; }
+            else if (tone == '4')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Digit_4; }
+            else if (tone == '5')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Digit_5; }
+            else if (tone == '6')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Digit_6; }
+            else if (tone == '7')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Digit_7; }
+            else if (tone == '8')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Digit_8; }
+            else if (tone == '9')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Digit_9; }
+            else if (tone == '*')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Asterisk; }
+            else if (tone == '#')
+            { event = org::freedesktop::Telepathy::DTMF_EVENT_Hash; }
+            else { return; }
+            info->channel->sendDTMFTone(event);
+        }
+        break;
+    case INCOMING:
+    case OUTGOING:
+        break;
+    default:
+        break;
+    }
+}
--- trunk/playground/pim/kcall/kcall/callmodel.h #693962:693963
@@ -64,6 +64,7 @@
          * @param subject The subject to set.
          */
         void setSubject(const int row, const QString & subject);
+        bool hasDTMFSupport(const QString & id);
 
         enum ColumnNames
         {
@@ -85,6 +86,7 @@
 
         void acceptCall(const QString & id);
         void hangupCall(const QString & id);
+        void sendDTMF(const QString & id, const QChar tone);
 
     private slots:
         void onChannelClosed();
--- trunk/playground/pim/kcall/kcall/kcallcore.cpp #693962:693963
@@ -39,21 +39,23 @@
 #include "kcallcore.h"
 #include "historymodel.h"
 #include "callmodel.h"
+#include "dtmfinput.h"
 
 KCallCore::KCallCore( KXMLGUIClient *client, bool readWrite, QWidget *parent,
                   const QString & /* file */, const char *name ) :
-      m_widget(new QWidget(parent)),
-      m_statusBar( 0 ),
-      m_readWrite( readWrite ),
-      m_modified( false ),
-      m_isPart(false),
-      m_actionSave(0),
-      m_addressBook(KABC::StdAddressBook::self( true )),
-      m_decibelDialer(new DecibelDialer(this)),
-      m_decibelChannelHandler(new DecibelChannelHandler(this)),
-      m_historyModel(new HistoryModel(this, this)),
-      m_callModel(new CallModel(this, this)),
-      m_guiClient( client )
+    m_widget(new QWidget(parent)),
+    m_statusBar( 0 ),
+    m_readWrite( readWrite ),
+    m_modified( false ),
+    m_isPart(false),
+    m_actionSave(0),
+    m_addressBook(KABC::StdAddressBook::self( true )),
+    m_decibelDialer(new DecibelDialer(this)),
+    m_decibelChannelHandler(new DecibelChannelHandler(this)),
+    m_historyModel(new HistoryModel(this, this)),
+    m_callModel(new CallModel(this, this)),
+    m_dtmfInput(new DTMFInput(this, parent)),
+    m_guiClient( client )
 {
     Decibel::registerTypes();
     setObjectName( name );
@@ -210,6 +212,7 @@
 
 void KCallCore::initGUI()
 {
+    // KCallGui:
     QVBoxLayout *topLayout = new QVBoxLayout( m_widget );
     topLayout->setSpacing( 0 );
     topLayout->setMargin( 0 );
@@ -228,22 +231,33 @@
             m_callModel, SLOT(acceptCall(const QString &)));
     connect(call_view, SIGNAL(reject(const QString &)),
             m_callModel, SLOT(hangupCall(const QString &)));
+    connect(call_view, SIGNAL(activeChannelSelected(const QString &)),
+            m_dtmfInput, SLOT(switchChannel(const QString &)));
 
+    connect(m_dtmfInput, SIGNAL(sendDTMF(const QString &, const QChar)),
+            m_callModel, SLOT(sendDTMF(const QString &, const QChar)));
+
     //connect( mDetails, SIGNAL( addressClicked( const QString&) ),
     //         this, SLOT( showContactsAddress( const QString& ) ) );
 
     initActions();
 }
 
-
 void KCallCore::initActions()
 {
     connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
              SLOT( clipboardDataChanged() ) );
 
-    QAction * action;
-    KActionCollection *coll = actionCollection();
+    QAction * action(0);
 
+    action = new KAction(this);
+    action->setText(i18n("send DTMF tones"));
+    action->setShortcut(Qt::CTRL + Qt::Key_D);
+    connect(action, SIGNAL(triggered(bool)),
+            this, SLOT(showDTMFInput()));
+    actionCollection()->addAction("dtmp_input", action);
+
+
   // file menu
 /*    mActionMail = coll->addAction( "file_mail" );
     mActionMail->setIcon( KIcon("mail-send") );
@@ -269,7 +283,7 @@
   // settings menu
     if ( m_isPart )
     {
-        action = coll->addAction("kcall_configure");
+        action = actionCollection()->addAction("kcall_configure");
         action->setIcon(KIcon("configure"));
         action->setText(i18n("&Configure KCall..."));
         connect(action, SIGNAL(triggered(bool) ), SLOT( configure() ));
@@ -288,49 +302,17 @@
             "Clears the content of the quick search bar." ) );
 */
 //    clipboardDataChanged();
+    showDTMFInput();
 }
 
 
 
 bool KCallCore::handleCommandLine()
 {
-/*
-    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-    QString addrStr = args->getOption( "addr" );
-    QString uidStr = args->getOption( "uid" );
-*/
-
-/*    OrgKdeKAddressbookCoreInterface interface("org.kde.KAddressbook", \
                "/KAddressbook", QDBusConnection::sessionBus());
-    QString addr, uid, vcard;
-    if ( !addrStr.isEmpty() )
-        addr = addrStr ;
-    if ( !uidStr.isEmpty() )
-        uid = uidStr;
-*/
     bool doneSomething = false;
 
-/*    if ( !addr.isEmpty() ) {
-        interface.addEmail( addr );
-        doneSomething = true;
-    }
+    // @todo: Add optionhandling here.
 
-    if ( !uid.isEmpty() ) {
-        interface.showContactEditor(uid );
-        doneSomething = true;
-    }
-
-    if ( args->isSet( "new-contact" ) ) {
-        interface.newContact();
-        doneSomething = true;
-    }
-
-    if ( args->count() >= 1 ) {
-        for ( int i = 0; i < args->count(); ++i ) {
-            interface.importVCard(args->url( i ).url() );
-        }
-        doneSomething = true;
-    }
-    */
     return doneSomething;
 }
 
@@ -340,7 +322,7 @@
 KABC::Addressee KCallCore::getPersonFromNumber(QString phoneNumber) const
 {
     addressBook()->load();
-    KABC::AddressBook::ConstIterator it; //is something like Addressee
+    KABC::AddressBook::ConstIterator it; // is something like Addressee
     for ( it = addressBook()->begin();
             it != addressBook()->end();
             ++it )
@@ -371,4 +353,21 @@
 CallModel * const KCallCore::callModel() const
 { return m_callModel; }
 
+void KCallCore::showDTMFInput()
+{
+    kDebug() << "KCallCore::showDTMFInput()" << endl;
+
+    // DTMFInput:
+    if (0 == m_dtmfInputDialog)
+    {
+        m_dtmfInputDialog = new KDialog();
+        m_dtmfInputDialog->setCaption(i18n("DTMF tones"));
+        m_dtmfInputDialog->setButtons(KDialog::Ok);
+        m_dtmfInputDialog->setMainWidget(m_dtmfInput);
+    }
+    Q_ASSERT(0 != m_dtmfInputDialog);
+    kDebug() << "KCallCore::showDTMFInput(): showing dialog." << endl;
+    m_dtmfInputDialog->show();
+}
+
 #include "kcallcore.moc"
--- trunk/playground/pim/kcall/kcall/kcallcore.h #693962:693963
@@ -33,11 +33,13 @@
 class KStatusBar;
 class KXMLGUIClient;
 class KAboutData;
+class KDialog;
 class KActionCollection;
 class DecibelDialer;
 class DecibelChannelHandler;
 class HistoryModel;
 class CallModel;
+class DTMFInput;
 
 class KCALL_EXPORT KCallCore : public QObject
 {
@@ -82,6 +84,9 @@
         HistoryModel * const historyModel() const;
         CallModel * const callModel() const;
 
+    protected slots:
+        void showDTMFInput();
+
     protected:
         void initGUI();
         void initActions();
@@ -101,13 +106,12 @@
         DecibelChannelHandler * const m_decibelChannelHandler;
         HistoryModel * const m_historyModel;
         CallModel * const m_callModel;
+        DTMFInput * const m_dtmfInput;
+        KDialog * m_dtmfInputDialog;
 
     private:
         KXMLGUIClient *m_guiClient;
         QPixmap m_statusPix[STATUS_MAX];
-
-        class KCallCorePrivate;
-        KCallCorePrivate *d;
 };
 
 #endif
--- trunk/playground/pim/kcall/kcall/kcallview.cpp #693962:693963
@@ -341,6 +341,9 @@
     foreach  (current_index, rows)
     {
         QVariant var(m_core->callModel()->data(current_index, Qt::UserRole));
+        QVariant call_id(m_core->callModel()->data(
+                         m_core->callModel()->index(current_index.row(),
+                                           CallModel::CALL_ID)));
         kDebug() << "KCallView::setButtonActions(): var is" << var << endl;
         CallStatus status(CallStatus(var.toInt()));
 
@@ -364,6 +367,7 @@
             ui.hangupButton->setEnabled(true);
             ui.acceptButton->setText(i18n("Dial"));
             ui.acceptButton->setEnabled(false);
+            emit activeChannelSelected(call_id.toString());
             break;
         default:
             kDebug() << "KCallView::setButtonActions(): default (" << status << ")" \
                << endl;
--- trunk/playground/pim/kcall/kcall/kcallview.h #693962:693963
@@ -68,11 +68,13 @@
     void setButtonActions();
 
 signals:
-    void accept(QString);
-    void reject(QString);
-    void hangup(QString);
-    void dial(QString);
+    void accept(const QString &);
+    void reject(const QString &);
+    void hangup(const QString &);
+    void dial(const QString &);
 
+    void activeChannelSelected(const QString &);
+
 protected:
     int m_callStatusCol;
     int m_actCallNrCol;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic