summaryrefslogtreecommitdiff
path: root/noncore/net/linphone/qlinphone.h
blob: 4192a4c700c021c7813f3c1abec0a1dbbd004223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/***************************************************************************
                          qlinphone.h  -  description
                             -------------------
    begin                : sam mai 24 2003
    copyright            : (C) 2003 by Simon Morlat, 2004 Maximilian Reiss
    email                : simon.morlat@linphone.org, harlekin@handhelds.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "mainwidget.h"
#include <qobject.h>
#include <qpushbutton.h>
#include <qqueue.h>
#include <pthread.h>

class GuiTask {
public:
    GuiTask(QWidget *w) {
        _w=w;
    }
    virtual void execute()=0;
    virtual ~GuiTask() {}
    ;
protected:
    QWidget *_w;
};

class ShowTask: public GuiTask {
public:
ShowTask(QWidget *w) : GuiTask(w) {}
    ;
private:
    void execute() {
        _w->show();
    }
};

class DisplaySomethingTask : public GuiTask {
public:
DisplaySomethingTask(QWidget* w,QString &msg): GuiTask(w) {
        _msg=msg;
    }
protected:
    QString _msg;
};

class UpdateStatusBarTask : public DisplaySomethingTask {
public:
UpdateStatusBarTask(QWidget *w,QString &msg) :DisplaySomethingTask(w,msg) {}
    ;
private:
    void execute();
};

class InviteReceivedTask : public DisplaySomethingTask {
public:
InviteReceivedTask(QWidget *w,QString &msg) :DisplaySomethingTask(w,msg) {}
    ;
private:
    void execute();
};

class DisplayMessageTask : public DisplaySomethingTask {
public:
    enum MessageType{Info,Warn};
DisplayMessageTask(QWidget *w,QString &msg,MessageType type) : DisplaySomethingTask(w,msg) {
        _msgtype=type;
    };
private:
    void execute();
    MessageType _msgtype;
};



typedef struct _LinphoneCore LinphoneCore;

class MyMutex {
public:
    MyMutex() {
        pthread_mutex_init(&_mutex,NULL);
    }
    void lock() {
        pthread_mutex_lock(&_mutex);
    }
    void unlock() {
        pthread_mutex_unlock(&_mutex);
    }
    ~MyMutex() {
        pthread_mutex_destroy(&_mutex);
    }
private:
    pthread_mutex_t _mutex;
};

class QLinphoneMainWidget : public _QLinphoneMainWidget {

Q_OBJECT

public:
    QLinphoneMainWidget(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
    ~QLinphoneMainWidget();

 
   void callOrAccept();
    void terminateCall();
    void inviteReceived(QString &from);
    void displayStatus(QString &status);
    void helpAbout();   
   // make it private
    void createLinphoneCore();
    void pushGuiTask(GuiTask* g);

private slots:
    void slotHide( bool show );

private:
    void readConfig();
    void writeConfig();
    void processGuiTasks();
    void timerEvent(QTimerEvent *);
    LinphoneCore *_core;
    QQueue<GuiTask> _actionq;
    MyMutex _mutex;
};