This repository has been archived by the owner on Apr 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kaccount.h
190 lines (131 loc) · 4.68 KB
/
kaccount.h
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#pragma once
#include <Stamina\PhonoLogic\Account.h>
#include <Stamina\PhonoLogic\PBCollectionEntry.h>
#include <Stamina\PhonoLogic\PhoneEntry.h>
#include <Stamina\PhonoLogic\CallArchiveEntry.h>
#include <Stamina\PhonoLogic\PhoneUrl.h>
using namespace Actio;
namespace Stamina {namespace PhonoLogic {
class KAccount:public Account {
public:
KAccount();
~KAccount();
std::string getUserAgent();
void connect(bool byUser);
void disconnect();
void onConnected();
void onDisconnected();
void onConnectionFailure();
void onConnecting();
virtual void onNewIncomingCall(const oCall& call);
virtual void onCriticalError(const CStdString& title, const CStdString& msg);
virtual void onUnauthorized();
virtual void onButtonPressed(PhoneButton button);
virtual void onConfigChanged();
virtual void onWindowActivated();
void onTapiHeaderWatchEvent(SIPX_HEADERWATCH_INFO* info);
void onInitialize();
virtual void createWindow();
virtual bool isConfigured();
virtual CStdString getSetting(const CStdString& name, const CStdString& def="") {
int id = Ctrl->DTgetNameID(DTCFG, ACTIO_CFG_PREFIX + name);
if (id == -1) return def;
return Ctrl->DTgetStr(DTCFG, 0, id);
}
virtual int getIntSetting(const CStdString& name, int def=0) {
int id = Ctrl->DTgetNameID(DTCFG, ACTIO_CFG_PREFIX + name);
if (id == -1) return def;
return Ctrl->DTgetInt(DTCFG, 0, id);
}
virtual void setSetting(const CStdString& name, const CStdString& value) {
Ctrl->DTsetStr(DTCFG, 0, ACTIO_CFG_PREFIX + name, value);
}
virtual void setSetting(const CStdString& name, int value) {
Ctrl->DTsetInt(DTCFG, 0, ACTIO_CFG_PREFIX + name, value);
}
virtual CStdString getSoundFile(const oCall& call, const CStdString& file);
//virtual void playFile(const oCall& call, const CStdString& file, bool loop = false);
CStdString phoneToDisplay(const PhoneUrl& url);
void callToHistory(const oCall& call);
void rejectedCallToHistory(const PhoneUrl& url, CallArchiveEntry::Type type);
void markPhoneAsUsed(const PhoneUrl& url);
bool updateCollectionBook(PBCollectionBook* entry, PBCollectionItem* item);
bool updateCollectionArchive(PBCollectionArchive* entry, PBCollectionItem* item);
bool isCalling(tCntId cnt);
void setVisibleStatus(int status);
int getVisibleStatus() {
return _visibleStatus;
}
void refreshAccountInfo();
bool getBalance(double& balance);
void refreshAccountInfoThread();
virtual CallEntry* createCallEntry(const oCall& call);
private:
int _visibleStatus;
double _balance;
bool _gotBalance;
bool _isFetchingInfo;
};
// ------------------
bool phoneEntryContextMenu(PBEntry* entry, ListWnd::ListView* lv, const ListWnd::oItem& li, int level, int vkey, const Point& pos, const oMenu& menu);
class KCallEntry: public CallEntry {
public:
KCallEntry(const oCall& call):CallEntry(call) {
}
bool onContextMenu(ListWnd::ListView* lv, const ListWnd::oItem& li, int level, int vkey, const Point& pos, const oMenu& menu);
void removePBEntry(PhoneBook* pb);
};
// ------------------
class PhoneEntryDT : public PhoneEntry
{
public:
PhoneEntryDT(tRowId);
public:
const PhoneUrl getPhoneUrl();
CStdString getName();
bool onContextMenu(ListWnd::ListView* lv, const ListWnd::oItem& li, int level, int vkey, const Point& pos, const oMenu& menu);
void removePBEntry(PhoneBook* pb);
private:
tRowId _row;
};
class PhoneEntryCnt : public PhoneEntry
{
public:
PhoneEntryCnt(const PhoneUrl& url, tColId cnt = -1);
public:
const PhoneUrl getPhoneUrl();
CStdString getName();
bool onContextMenu(ListWnd::ListView* lv, const ListWnd::oItem& li, int level, int vkey, const Point& pos, const oMenu& menu);
void removePBEntry(PhoneBook* pb);
private:
PhoneUrl _url;
tCntId _cnt;
};
class CallArchiveEntryDT:public CallArchiveEntry {
public:
CallArchiveEntryDT(tRowId row, bool outgoing)
:_row(row), _outgoing(outgoing) {}
Time64 getCallTime() {
return this->getTable()->getInt64(_row, DTArchive::start);
}
Time64 getCallDuration() {
return this->getTable()->getInt64(_row, DTArchive::duration);
}
bool isOutgoing() {
return _outgoing;
}
Type getType() {
return (Type) this->getTable()->getInt(_row, DTArchive::type);
}
const PhoneUrl getPhoneUrl() {
return PhoneUrl::createAuto(this->getTable()->getStr(_row, DTArchive::phone));
}
CStdString getName();
bool onContextMenu(ListWnd::ListView* lv, const ListWnd::oItem& li, int level, int vkey, const Point& pos, const oMenu& menu);
void removePBEntry(PhoneBook* pb);
protected:
Tables::oTable getTable();
tRowId _row;
bool _outgoing;
};
};};