forked from yohanson/astercti
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyapp.cpp
More file actions
67 lines (60 loc) · 2.2 KB
/
myapp.cpp
File metadata and controls
67 lines (60 loc) · 2.2 KB
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
#ifdef WX_PRECOMP
#include <wx/wxprec.h>
#else
#include <wx/wx.h>
#endif
#include <wx/string.h>
#include "controller.h"
#include "asterisk.h"
#include "notificationFrame.h"
#include "mainframe.h"
#include "myapp.h"
#include "taskbaricon.h"
wxIMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
m_config = NULL;
m_config = new wxFileConfig(wxT("astercti"),
wxEmptyString,
wxT("astercti.ini"),
wxEmptyString,
wxCONFIG_USE_SUBDIR);
if (!m_config)
{
std::cerr << "Error opening config file." << std::endl;
return false;
}
std::cout << "Filename: " << m_config->GetLocalFileName("astercti.ini", wxCONFIG_USE_SUBDIR) << std::endl;
MyFrame *frame = new MyFrame( "AsterCTI", wxDefaultPosition, wxSize(450, 340) );
SetExitOnFrameDelete(true);
frame->Show( true );
SetTopWindow(frame);
std::cout << "addr: " << m_config->Read("server/address") << std::endl;
Asterisk *asterisk = new Asterisk(m_config->Read("server/address").ToStdString(),
5038,
m_config->Read("server/username").ToStdString(),
m_config->Read("server/password").ToStdString());
m_controller = new AsteriskController(
asterisk,
m_config->Read("dialplan/context").ToStdString(),
m_config->Read("dialplan/channel").ToStdString(),
m_config->Read("dialplan/exten").ToStdString()
);
m_controller->SetMainFrame(frame);
MyChanFilter *mychanfilter = new MyChanFilter(m_config->Read("dialplan/channel").ToStdString());
asterisk->add(*mychanfilter);
mychanfilter->add(*frame);
notificationFrame *notifyframe = new notificationFrame(frame);
notifyframe->SetLookupCmd(m_config->Read("commands/lookup").ToStdString());
mychanfilter->add(*notifyframe);
wxString iconfile = m_config->Read("gui/icon");
wxIcon iconimage(iconfile, wxBITMAP_TYPE_PNG);
frame->SetIcon(iconimage);
MyTaskBarIcon *icon = new MyTaskBarIcon(iconimage);
icon->SetMainFrame(frame);
m_controller->add(icon);
m_controller->add(frame);
m_controller->add(notifyframe);
std::cout << "ExitOnFrameDelete: " << GetExitOnFrameDelete() << std::endl;
return true;
}