~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to protocols/sms/services/gsmlib.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  gsmlib.h  -  SMS Plugin
 
3
 
 
4
  Copyright (c) 2005      by Justin Huff        <jjhuff@mspin.net>
 
5
 
 
6
  *************************************************************************
 
7
  *                                                                       *
 
8
  * This program is free software; you can redistribute it and/or modify  *
 
9
  * it under the terms of the GNU General Public License as published by  *
 
10
  * the Free Software Foundation; either version 2 of the License, or     *
 
11
  * (at your option) any later version.                                   *
 
12
  *                                                                       *
 
13
  *************************************************************************
 
14
*/
 
15
 
 
16
#ifndef GSMLIB_H_039562406
 
17
#define GSMLIB_H_039562406
 
18
 
 
19
#include <config-kopete.h>
 
20
//Added by qt3to4:
 
21
#include <Q3GridLayout>
 
22
#include <QCustomEvent>
 
23
#ifdef INCLUDE_SMSGSM
 
24
 
 
25
#include <unistd.h>
 
26
 
 
27
#include <gsmlib/gsm_unix_serial.h>
 
28
#include <gsmlib/gsm_sms.h>
 
29
#include <gsmlib/gsm_me_ta.h>
 
30
#include <gsmlib/gsm_util.h>
 
31
#include <gsmlib/gsm_event.h>
 
32
 
 
33
#include "smsservice.h"
 
34
#include "kopetemessage.h"
 
35
 
 
36
#include <QThread>
 
37
#include <QMutex>
 
38
#include <QList>
 
39
#include <QStringList>
 
40
 
 
41
class GSMLibPrefsUI;
 
42
class QGridLayout;
 
43
class GSMLibThread;
 
44
 
 
45
class GSMLib : public SMSService
 
46
{
 
47
    Q_OBJECT
 
48
public:
 
49
    GSMLib(Kopete::Account* account);
 
50
    ~GSMLib();
 
51
 
 
52
    void send(const Kopete::Message& msg);
 
53
    void setWidgetContainer(QWidget* parent, QGridLayout* container);
 
54
 
 
55
    int maxSize();
 
56
    const QString& description();
 
57
 
 
58
public slots:
 
59
    void savePreferences();
 
60
        virtual void connect();
 
61
        virtual void disconnect();
 
62
 
 
63
//signals:
 
64
//      void messageSent(const Kopete::Message &);
 
65
protected:
 
66
        virtual void customEvent(QCustomEvent* e);
 
67
 
 
68
    QWidget* configureWidget(QWidget* parent);
 
69
        void saveConfig();
 
70
        void loadConfig();
 
71
 
 
72
    GSMLibPrefsUI* prefWidget;
 
73
    QStringList output;
 
74
 
 
75
        QString m_device;
 
76
 
 
77
    QString m_description;
 
78
 
 
79
        GSMLibThread* m_thread;
 
80
 
 
81
} ;
 
82
 
 
83
 
 
84
/// Custom event for async-events
 
85
class GSMLibEvent : public QCustomEvent
 
86
{
 
87
public:
 
88
        enum SubType { CONNECTED, DISCONNECTED, NEW_MESSAGE, MSG_SENT, MSG_NOT_SENT };
 
89
 
 
90
        GSMLibEvent(SubType t);
 
91
 
 
92
        SubType subType();
 
93
        void setSubType(SubType t);
 
94
 
 
95
        QString Text;
 
96
        QString Number;
 
97
 
 
98
        QString Reason;
 
99
 
 
100
        Kopete::Message Message;
 
101
protected:
 
102
        SubType m_subType;
 
103
};
 
104
 
 
105
/// Thread to deal with GsmLib's blocking
 
106
class GSMLibThread : public QThread, gsmlib::GsmEvent
 
107
{
 
108
public:
 
109
        GSMLibThread(QString dev, GSMLib* parent);
 
110
        virtual ~GSMLibThread();
 
111
 
 
112
        virtual void run();
 
113
        void stop();
 
114
        void send(const Kopete::Message& msg);
 
115
protected:
 
116
        bool doConnect();
 
117
        void pollForMessages();
 
118
        void sendMessageQueue();
 
119
        void sendMessage(const Kopete::Message& msg);
 
120
    void SMSReception(gsmlib::SMSMessageRef newMessage, SMSMessageType messageType);
 
121
    void SMSReceptionIndication(std::string storeName, unsigned int index, SMSMessageType messageType);
 
122
 
 
123
        GSMLib* m_parent;
 
124
        QString m_device;
 
125
 
 
126
    gsmlib::MeTa* m_MeTa;
 
127
 
 
128
        bool m_run;
 
129
 
 
130
    struct IncomingMessage
 
131
    {
 
132
        int Index;
 
133
        QString StoreName;
 
134
        gsmlib::SMSMessageRef Message;
 
135
        GsmEvent::SMSMessageType Type;
 
136
 
 
137
        IncomingMessage() :   Index(-1)
 
138
        {}
 
139
    };
 
140
 
 
141
    typedef QList<IncomingMessage> MessageList;
 
142
    MessageList m_newMessages;
 
143
 
 
144
        typedef QList<Kopete::Message> KopeteMessageList;
 
145
        KopeteMessageList m_outMessages;
 
146
        QMutex m_outMessagesMutex;
 
147
};
 
148
 
 
149
#endif
 
150
#endif //GSMLIB_H_039562406