2 Copyright (C) 2011 by Cuong Le <metacuong@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>
22 #include <QtSql/QSqlDatabase>
26 #define H_TOTAL_GROUP_BY "select remote_name, count(*) from Events E, Remotes R where R.remote_uid=E.remote_uid and E.local_uid=R.local_uid %1 %2 group by remote_name order by start_time desc"
27 #define H_DEFAULT_SEARCH "select event_type_id, start_time, end_time, is_read, E.local_uid, E.remote_uid, free_text, outgoing, remote_name from Events E, Remotes R where R.remote_uid=E.remote_uid and E.local_uid=R.local_uid %1 order by start_time desc limit %2"
29 #define P_TYPE_GSM_NETWORK "ring/tel/ring"
30 #define P_TYPE_SKYPE "spirit/skype"
31 #define P_TYPE_JABBER "gabble/jabber"
33 #define ICONS_ROOT_DIR "/usr/share/icons/hicolor/"
35 #define IMG_AVATAR ICONS_ROOT_DIR "48x48/hildon/general_default_avatar.png"
36 #define IMG_OUTGOING ICONS_ROOT_DIR "48x48/hildon/general_sent.png"
37 #define IMG_INCOMING ICONS_ROOT_DIR "48x48/hildon/general_received.png"
38 #define IMG_MISSED ICONS_ROOT_DIR "48x48/hildon/general_missed.png"
40 #define IMG_CELL ICONS_ROOT_DIR "32x32/hildon/call_status_cellular.png"
41 #define IMG_SKYPE ICONS_ROOT_DIR "32x32/hildon/general_skype.png"
42 #define IMG_GOOGLE ICONS_ROOT_DIR "32x32/hildon/general_gtalk.png"
43 #define IMG_SIP ICONS_ROOT_DIR "32x32/hildon/general_sip.png"
44 #define IMG_OVI ICONS_ROOT_DIR "32x32/hildon/general_ovi.png"
45 #define IMG_JABBER ICONS_ROOT_DIR "32x32/hildon/general_jabber.png"
48 The record class for group by informations first screen
50 class elv1rec : public QObject
56 m_avatar(QIcon::fromTheme( "general_default_avatar", QIcon(IMG_AVATAR)))
60 QString contact_name() const{
61 return m_contact_name;
64 QString total_call() const{
72 void set_contact_name(QString contact_name){
73 m_contact_name = contact_name;
76 void set_total_call(QString total_call){
77 m_total_call = total_call;
80 void set_avatar(QIcon avatar){
85 QString m_contact_name;
91 The record class for detail informations second screen
93 enum PhoneType { GSM_NETWORK = 0, SKYPE = 1, JABBER = 2, GOOGLE_TALK = 3, UNKNOW = 4};
94 enum CallType { OUTGOING = 0, INCOMING = 1, MISSED = 2, ALL_CALL = 3};
96 class elv1Detailrec : public QObject
105 void set_phonenumber(QString phonenumber){ m_phonenumber = phonenumber;}
106 void set_starttime(uint starttime){ m_starttime.setTime_t(starttime);}
107 void set_endtime(uint endtime){ m_endtime.setTime_t(endtime);}
108 void set_calltype(CallType calltype){
109 m_calltype = calltype;
110 m_icon = QIcon::fromTheme(calltype==OUTGOING?
111 "general_sent":calltype==INCOMING?
112 "general_received":"general_missed", QIcon(calltype==OUTGOING?
113 IMG_OUTGOING:calltype==INCOMING?
114 IMG_INCOMING:IMG_MISSED));
118 void set_phonetype(PhoneType phonetype){
119 m_phonetype = phonetype;
120 QString _m_icon_meta;
121 QString _m_icon_path;
124 _m_icon_meta = "call_status_cellular";
125 _m_icon_path = IMG_CELL;
128 _m_icon_meta = "general_skype";
129 _m_icon_path = IMG_SKYPE;
132 _m_icon_meta = "general_jabber";
133 _m_icon_path = IMG_JABBER;
136 _m_icon_meta = "general_gtalk";
137 _m_icon_path = IMG_GOOGLE;
140 _m_icon_meta = "call_status_unknow";
141 _m_icon_path = "unknow";
145 m_type_call_icon = QIcon::fromTheme(_m_icon_meta, QIcon(_m_icon_path));
148 void set_callduration(uint callduration){ m_callduration = callduration;}
150 QString get_phonenumber() const { return m_phonenumber;}
151 QIcon get_icon() const { return m_icon;}
152 QIcon get_type_call_icon() const { return m_type_call_icon;}
153 QTime get_starttime() const { return m_starttime.time();}
154 QTime get_endtime() const { return m_endtime.time();}
155 QDate get_startdate() const { return m_starttime.date();}
156 QDate get_enddate() const { return m_endtime.date();}
157 CallType get_calltype() const { return m_calltype;}
158 uint get_duration() const { return m_callduration;}
161 QIcon m_icon; //incoming/outgoing/missed call icons
162 QIcon m_type_call_icon; //cell/skype/sip/jingle/...
163 QString m_phonenumber;
164 QDateTime m_starttime;
167 PhoneType m_phonetype;
172 The main db management class
173 *MUST* be inherited QThread
177 class elv1db : public QThread
181 explicit elv1db(QObject *parent = 0);
186 void setQuery(QString o_query) {
190 QString m_contact_name;
192 QList<elv1rec*> m_records;
193 QList<elv1Detailrec*> m_detail_records;
198 CallType m_call_type;
201 void start_indicator();
202 void group_by_finished();
203 void detail_finished();
204 void detail_start_indicator();
210 PhoneType phonetype(QString metastr);