Creation
This commit is contained in:
commit
9f5b83c776
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/SystemGui.pro.user
|
||||||
|
/Makefile
|
||||||
|
/Makefile.Debug
|
||||||
|
/Makefile.Release
|
||||||
|
/object_script.MasterInterface.Debug
|
||||||
|
/object_script.MasterInterface.Release
|
||||||
|
/object_script.SystemGui.Debug
|
||||||
|
/object_script.SystemGui.Release
|
||||||
|
/debug
|
||||||
|
/release
|
||||||
BIN
Configuration/Settings.mcs
Normal file
BIN
Configuration/Settings.mcs
Normal file
Binary file not shown.
BIN
Ico/back.png
Normal file
BIN
Ico/back.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
BIN
Ico/close.png
Normal file
BIN
Ico/close.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.4 KiB |
BIN
Ico/contact.png
Normal file
BIN
Ico/contact.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
Ico/icon.png
Normal file
BIN
Ico/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
BIN
Ico/sms.png
Normal file
BIN
Ico/sms.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
BIN
Ico/sms_new.png
Normal file
BIN
Ico/sms_new.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
136
SMSGui.ui
Normal file
136
SMSGui.ui
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CSMSGui</class>
|
||||||
|
<widget class="QWidget" name="CSMSGui">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>803</width>
|
||||||
|
<height>785</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QTextBrowser" name="mConversationText">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>160</y>
|
||||||
|
<width>481</width>
|
||||||
|
<height>451</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QFrame" name="mSMSEditFrame">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>620</y>
|
||||||
|
<width>521</width>
|
||||||
|
<height>121</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QPushButton" name="mSMSSendBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Send</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" rowspan="2">
|
||||||
|
<widget class="QTextEdit" name="mSMSEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="3">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2" colspan="2">
|
||||||
|
<widget class="QLabel" name="mSMSMessageStatsLabel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTreeWidget" name="mContactsTreeWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>520</x>
|
||||||
|
<y>160</y>
|
||||||
|
<width>256</width>
|
||||||
|
<height>471</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="indentation">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<attribute name="headerVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">1</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="mContactPic">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>141</width>
|
||||||
|
<height>121</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="mContactName">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>180</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>591</width>
|
||||||
|
<height>101</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
10
Sources/AbstractNetworkInterface.h
Normal file
10
Sources/AbstractNetworkInterface.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef ABSTRACTNETWORKINTERFACE_H
|
||||||
|
#define ABSTRACTNETWORKINTERFACE_H
|
||||||
|
#include <QByteArray>
|
||||||
|
|
||||||
|
class CAbstractNetworkCommIF
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual int NewFrameReceived(QByteArray Frame) = 0;
|
||||||
|
};
|
||||||
|
#endif // ABSTRACTNETWORKINTERFACE_H
|
||||||
9
Sources/GlobalDefine.h
Normal file
9
Sources/GlobalDefine.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef GLOBALDEFINE_H
|
||||||
|
#define GLOBALDEFINE_H
|
||||||
|
|
||||||
|
#include "QDebug"
|
||||||
|
|
||||||
|
#define RET_OK 1
|
||||||
|
#define RET_ERROR 0
|
||||||
|
|
||||||
|
#endif // GLOBALDEFINE_H
|
||||||
45
Sources/GuiMain.cpp
Normal file
45
Sources/GuiMain.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#include "GuiMain.h"
|
||||||
|
#include <QWindowStateChangeEvent>
|
||||||
|
|
||||||
|
CGuiMain::CGuiMain(QWidget *parent)
|
||||||
|
: QMainWindow(parent)
|
||||||
|
{
|
||||||
|
mSMSGui = new CSMSGui(this);
|
||||||
|
mSprinklerGui = new CSprinklerGui(this);
|
||||||
|
mMainTabWidget = new QTabWidget(this);
|
||||||
|
setCentralWidget(mMainTabWidget);
|
||||||
|
mMainTabWidget->addTab(mSMSGui,"SMS");
|
||||||
|
mMainTabWidget->addTab(mSprinklerGui,"Sprinkler");
|
||||||
|
resize(1024,768);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGuiMain::~CGuiMain()
|
||||||
|
{
|
||||||
|
// delete mSMSGui;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CGuiMain::RespawnMainWindow()
|
||||||
|
{
|
||||||
|
// qDebug("Respawn");
|
||||||
|
activateWindow();
|
||||||
|
showNormal();
|
||||||
|
raise();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGuiMain::changeEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
// qDebug("State Changed");
|
||||||
|
if (event->type() == QEvent::WindowStateChange)
|
||||||
|
{
|
||||||
|
// qDebug("Window state");
|
||||||
|
QWindowStateChangeEvent* WinEvent = (QWindowStateChangeEvent*)event;
|
||||||
|
if(window()->isMinimized() && ((WinEvent->oldState() != Qt::WindowMinimized)))
|
||||||
|
{
|
||||||
|
qDebug("Minimized");
|
||||||
|
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
28
Sources/GuiMain.h
Normal file
28
Sources/GuiMain.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#ifndef GUIMAIN_H
|
||||||
|
#define GUIMAIN_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QStackedWidget>
|
||||||
|
#include "SMSGui.h"
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include "SprinklerGui.h"
|
||||||
|
|
||||||
|
class CGuiMain : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CGuiMain(QWidget *parent = 0);
|
||||||
|
~CGuiMain();
|
||||||
|
|
||||||
|
CSMSGui *mSMSGui;
|
||||||
|
CSprinklerGui *mSprinklerGui;
|
||||||
|
QTabWidget *mMainTabWidget;
|
||||||
|
int RespawnMainWindow();
|
||||||
|
int HideMainWindow();
|
||||||
|
|
||||||
|
virtual void changeEvent(QEvent* event);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GUIMAIN_H
|
||||||
96
Sources/MasterCtrlInterface.cpp
Normal file
96
Sources/MasterCtrlInterface.cpp
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#include "MasterCtrlInterface.h"
|
||||||
|
|
||||||
|
CMasterCtrlInterface::CMasterCtrlInterface()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CMasterCtrlInterface::ConnectToMasterCtrl()
|
||||||
|
{
|
||||||
|
if(mNetworkCommSocket == 0)
|
||||||
|
{
|
||||||
|
mNetworkCommSocket = new QTcpSocket();
|
||||||
|
}
|
||||||
|
connect(mNetworkCommSocket,SIGNAL(connected()),this,SLOT(NetworkSocketConnected()));
|
||||||
|
connect(mNetworkCommSocket,SIGNAL(disconnected()),this,SLOT(NetworkSocketDisconnected()));
|
||||||
|
connect(mNetworkCommSocket,SIGNAL(readyRead()),this,SLOT(NetworkSocketDataAvailable()));
|
||||||
|
|
||||||
|
mNetworkCommSocket->connectToHost(mMasterCtrlAddress,mNetworkPort);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CMasterCtrlInterface::DisconnectMasterCtrl()
|
||||||
|
{
|
||||||
|
if(mNetworkCommSocket != 0)
|
||||||
|
{
|
||||||
|
mNetworkCommSocket->close();
|
||||||
|
// mNetworkCommSocket->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CMasterCtrlInterface::NewFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(TargetDeviceID == ID_ETHERNET_VIRTUAL)
|
||||||
|
{
|
||||||
|
switch(MessageID)
|
||||||
|
{
|
||||||
|
case ETH_NETWK_DEVICE_INFO_REQUEST:
|
||||||
|
{
|
||||||
|
QByteArray Frame,ResponseData;
|
||||||
|
ResponseData.append((char)mMyDeviceID);
|
||||||
|
ResponseData.append((char)mDeviceAddress);
|
||||||
|
Frame = GetTxPacket(ETH_NETWK_DEVICE_INFO_RESPONSE,0,ResponseData.data(),ResponseData.size(),1,ID_MASTER,ID_ETHERNET_VIRTUAL,mDeviceAddress);
|
||||||
|
mNetworkCommSocket->write(Frame);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ETH_NETWK_CONNECTION_REFUSED:
|
||||||
|
{
|
||||||
|
qDebug("MasterCtrl connection refused");
|
||||||
|
mNetworkCommSocket->close();
|
||||||
|
delete mNetworkCommSocket;
|
||||||
|
mNetworkCommSocket = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ETH_NETWK_SET_DEVICE_INFO_ACK:
|
||||||
|
{
|
||||||
|
// mNetworkCommSocket->write(GetTxPacket(SMS_CLIENT_DEVICE_DID_INFO_REQUEST,0,0,0,1,ID_MASTER,ID_SMS_CLIENT,mDeviceAddress));
|
||||||
|
DeviceConnectedToMaster();
|
||||||
|
qDebug("MasterCtrl accepted connection");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ETH_NETWK_DEVICE_INFO_RESPONSE:
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DeviceFrameReceived(TargetDeviceID, TargetDeviceAddress, SenderID, SenderAddress, MessageID, DataSize, Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMasterCtrlInterface::NetworkSocketConnected()
|
||||||
|
{
|
||||||
|
qDebug("Connected to MasterCtrl");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMasterCtrlInterface::NetworkSocketDataAvailable()
|
||||||
|
{
|
||||||
|
AnalyzeRxBuffer(mNetworkCommSocket->readAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMasterCtrlInterface::NetworkSocketDisconnected()
|
||||||
|
{
|
||||||
|
qDebug("Disconnected from MasterCtrl");
|
||||||
|
|
||||||
|
}
|
||||||
39
Sources/MasterCtrlInterface.h
Normal file
39
Sources/MasterCtrlInterface.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#ifndef MASTERCTRLINTERFACE_H
|
||||||
|
#define MASTERCTRLINTERFACE_H
|
||||||
|
#include <QObject>
|
||||||
|
#include "NetworkProtocol.h"
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include "ProtocolDefs.h"
|
||||||
|
#include <QTcpSocket>
|
||||||
|
#include "SMSMessage.h"
|
||||||
|
|
||||||
|
class CMasterCtrlInterface : public QObject, public CNetworkProtocol
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CMasterCtrlInterface();
|
||||||
|
|
||||||
|
|
||||||
|
QTcpSocket *mNetworkCommSocket;
|
||||||
|
int mDeviceAddress;
|
||||||
|
int mNetworkPort;
|
||||||
|
QString mMasterCtrlAddress;
|
||||||
|
int mMyDeviceID;
|
||||||
|
|
||||||
|
int ConnectToMasterCtrl();
|
||||||
|
int DisconnectMasterCtrl();
|
||||||
|
virtual int NewFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data);
|
||||||
|
|
||||||
|
virtual int DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data) = 0;
|
||||||
|
virtual int DeviceConnectedToMaster(bool Connected = true) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void NetworkSocketConnected();
|
||||||
|
void NetworkSocketDataAvailable();
|
||||||
|
void NetworkSocketDisconnected();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MASTERCTRLINTERFACE_H
|
||||||
379
Sources/NetworkProtocol.cpp
Normal file
379
Sources/NetworkProtocol.cpp
Normal file
@ -0,0 +1,379 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "NetworkProtocol.h"
|
||||||
|
|
||||||
|
|
||||||
|
CNetworkProtocol::CNetworkProtocol()
|
||||||
|
{
|
||||||
|
mIsResetManual = false;
|
||||||
|
ResetRxStateMachine();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CNetworkProtocol::~CNetworkProtocol()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//void CNetworkProtocol::BindUpperLayer(CMasterCtrl *UpperLayerPtr)
|
||||||
|
//{
|
||||||
|
// mMasterCtrlHandle = UpperLayerPtr;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned char CNetworkProtocol::CalcCRC(char *Buffer, int Size)
|
||||||
|
{
|
||||||
|
unsigned char CRC = 0x00;
|
||||||
|
|
||||||
|
for( int i = 0; i < Size; i++)
|
||||||
|
{
|
||||||
|
CRC ^= Buffer[i];
|
||||||
|
}
|
||||||
|
return CRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray CNetworkProtocol::GetTxPacket(unsigned char MessageID, unsigned char Flags, const char *Data, int Size, unsigned char Address, unsigned char ID, unsigned char SenderDevice, unsigned char SenderAddress)
|
||||||
|
{
|
||||||
|
#ifdef USE_BYTEARRAY_IN_SEND
|
||||||
|
|
||||||
|
QByteArray Frame;
|
||||||
|
Frame.clear();
|
||||||
|
int FrameSize = Size + 11; //Add header data...
|
||||||
|
|
||||||
|
Frame.append(FRAME_HEADER); //header
|
||||||
|
Frame.append(SenderAddress); //Device address (default = MasterCtrl)
|
||||||
|
Frame.append(SenderDevice); //Device ID (default = MasterCtrl
|
||||||
|
Frame.append(ID); //destination ID
|
||||||
|
Frame.append(Address); //Destination Address
|
||||||
|
Frame.append(Flags);
|
||||||
|
Frame.append(MessageID); //Cmd
|
||||||
|
Frame.append((Size & 0xFF000000) >> 24);
|
||||||
|
Frame.append((Size & 0x00FF0000) >> 16);
|
||||||
|
Frame.append((Size & 0x0000FF00) >> 8);
|
||||||
|
Frame.append(Size & 0x000000FF);
|
||||||
|
Frame.append(Data,Size);
|
||||||
|
char CRC = CalcCRC(Frame.data(),FrameSize);
|
||||||
|
Frame.append(CRC);
|
||||||
|
|
||||||
|
return Frame;
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
int toto;
|
||||||
|
char temp;
|
||||||
|
char OutBuffer[MAX_MESSAGE_SIZE+10];
|
||||||
|
|
||||||
|
int FrameSize = Size + 9; //Add header data...
|
||||||
|
|
||||||
|
OutBuffer[0] = (char)FRAME_HEADER; //header
|
||||||
|
OutBuffer[1] = SenderAddress; //Device address (default = MasterCtrl)
|
||||||
|
OutBuffer[2] = SenderDevice; //Device ID (default = MasterCtrl
|
||||||
|
OutBuffer[3] = (char)ID; //destination ID
|
||||||
|
OutBuffer[4] = (char)Address; //Destination Address
|
||||||
|
OutBuffer[5] = (char)Flags;
|
||||||
|
OutBuffer[6] = (char)MessageID; //Cmd
|
||||||
|
// toto = FrameSize & 0xFF00;
|
||||||
|
temp = FrameSize >> 8;
|
||||||
|
OutBuffer[7] = ((FrameSize - 9) & 0xFF00) >> 8;
|
||||||
|
OutBuffer[8] = (FrameSize - 9) & 0x00FF;
|
||||||
|
|
||||||
|
for(int i = 0; i < Size; i++)
|
||||||
|
{
|
||||||
|
temp = Data[i];
|
||||||
|
OutBuffer[i+9] = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
OutBuffer[FrameSize] = CalcCRC(OutBuffer,FrameSize);
|
||||||
|
|
||||||
|
|
||||||
|
// CSerialComm::instance()->WriteData(&OutBuffer[0],FrameSize+1);
|
||||||
|
|
||||||
|
return QByteArray(OutBuffer,FrameSize);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//int CNetworkProtocol::TxData(unsigned char MessageID,unsigned char Flags,unsigned char *Data,int Size, unsigned char Address,unsigned char ID)
|
||||||
|
//{
|
||||||
|
|
||||||
|
// int toto;
|
||||||
|
// char temp;
|
||||||
|
// char OutBuffer[MAX_MESSAGE_SIZE+10];
|
||||||
|
|
||||||
|
// int FrameSize = Size + 9; //Add header data...
|
||||||
|
|
||||||
|
// OutBuffer[0] = (char)FRAME_HEADER; //header
|
||||||
|
// OutBuffer[1] = 1; //MasterCtrl address
|
||||||
|
// OutBuffer[2] = ID_MASTER; //MasterCtrl ID
|
||||||
|
// OutBuffer[3] = (char)ID; //destination ID
|
||||||
|
// OutBuffer[4] = (char)Address; //Destination Address
|
||||||
|
// OutBuffer[5] = (char)Flags;
|
||||||
|
// OutBuffer[6] = (char)MessageID; //Cmd
|
||||||
|
// toto = FrameSize & 0xFF00;
|
||||||
|
// temp = FrameSize >> 8;
|
||||||
|
// OutBuffer[7] = ((FrameSize - 9) & 0xFF00) >> 8;
|
||||||
|
// OutBuffer[8] = (FrameSize - 9) & 0x00FF;
|
||||||
|
|
||||||
|
// for(int i = 0; i < Size; i++)
|
||||||
|
// {
|
||||||
|
// temp = Data[i];
|
||||||
|
// OutBuffer[i+9] = temp;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// OutBuffer[FrameSize] = CalcCRC(OutBuffer,FrameSize);
|
||||||
|
|
||||||
|
|
||||||
|
//// CSerialComm::instance()->WriteData(&OutBuffer[0],FrameSize+1);
|
||||||
|
|
||||||
|
// return 0;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CNetworkProtocol::ReadPort(void)
|
||||||
|
//{
|
||||||
|
// int Size = 0;
|
||||||
|
// RxBuff = CSerialComm::instance()->ReceiveData(Size);
|
||||||
|
// if(Size)
|
||||||
|
// {
|
||||||
|
// if(Size > 50)
|
||||||
|
// {
|
||||||
|
// int toto = 5;
|
||||||
|
// }
|
||||||
|
//// TRACE("Received %d bytes\n",Size);
|
||||||
|
// AnalyseNewData(RxBuff,Size);
|
||||||
|
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CNetworkProtocol::AnalyseNewData(char *Data, int size)
|
||||||
|
//{
|
||||||
|
// if(size != 0)
|
||||||
|
// {
|
||||||
|
// for(int i(0); i < size; i++)
|
||||||
|
// {
|
||||||
|
// StateMachine((unsigned char)Data[i]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
int CNetworkProtocol::RxStateMachine(unsigned char Data)
|
||||||
|
{
|
||||||
|
int ret = PROTOCOL_RET_OK_PACKET_INCOMPLETE;
|
||||||
|
|
||||||
|
switch(RxState)
|
||||||
|
{
|
||||||
|
case RxHeader: //Wait for data header...
|
||||||
|
{
|
||||||
|
if((unsigned char)Data == FRAME_HEADER)
|
||||||
|
{
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
RxState = RxAdd;
|
||||||
|
CRC ^= Data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ResetRxStateMachine();
|
||||||
|
ret = PROTOCOL_RET_OK_BAD_HEADER;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxAdd: //Sender Address.
|
||||||
|
{
|
||||||
|
SenderAddress = Data;
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
RxState = RxID;
|
||||||
|
CRC ^= Data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxID: //Sender ID
|
||||||
|
{
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
RxState = RxMyID;
|
||||||
|
SenderID = Data;
|
||||||
|
CRC ^= Data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxMyID:
|
||||||
|
{
|
||||||
|
|
||||||
|
// if(Data != ID_MASTER && Data != 0xFF) //Message is not for Master and it's not a broadcast
|
||||||
|
// {
|
||||||
|
// ResetRxStateMachine();
|
||||||
|
// ret = PROTOCOL_RET_ERROR_INVALID_TARGET_DEVICE;
|
||||||
|
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
TargetDeviceID = Data;
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
RxState = RxMyAddress;
|
||||||
|
CRC ^= Data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxMyAddress:
|
||||||
|
{
|
||||||
|
// if(Data != 1 && Data != 0xFF) //Message is not for us and it's not a broadcast
|
||||||
|
// {
|
||||||
|
// ResetRxStateMachine();
|
||||||
|
// ret = PROTOCOL_RET_ERROR_INVALID_TARGET_ADDRESS;
|
||||||
|
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
TargetAddress = Data;
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
RxState = RxFlags;
|
||||||
|
CRC ^= Data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxFlags:
|
||||||
|
{
|
||||||
|
Flags = Data;
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
RxState = RxCMD;
|
||||||
|
CRC ^= Data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxCMD:
|
||||||
|
{
|
||||||
|
RxCmd = Data;
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
RxState = RxSize1;
|
||||||
|
CRC ^= Data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxSize1: //Data size MSB
|
||||||
|
{
|
||||||
|
RxSize = 0;
|
||||||
|
RxSize = (unsigned int)Data;
|
||||||
|
RxSize <<= 8;
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
|
||||||
|
|
||||||
|
RxState = RxSize2;
|
||||||
|
CRC ^= Data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxSize2: //Data size MSB
|
||||||
|
{
|
||||||
|
RxSize |= (unsigned int)Data;
|
||||||
|
RxSize <<= 8;
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
|
||||||
|
|
||||||
|
RxState = RxSize3;
|
||||||
|
CRC ^= Data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxSize3: //Data size MSB
|
||||||
|
{
|
||||||
|
RxSize |= (unsigned int)Data;
|
||||||
|
RxSize <<= 8;
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
|
||||||
|
|
||||||
|
RxState = RxSize4;
|
||||||
|
CRC ^= Data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxSize4: //Data size LSB
|
||||||
|
{
|
||||||
|
RxSize |= (unsigned int)Data;
|
||||||
|
mRxData[BufPtr++] = Data;
|
||||||
|
|
||||||
|
if(RxSize == 0)
|
||||||
|
RxState = RxCRC;
|
||||||
|
else
|
||||||
|
RxState = RxData;
|
||||||
|
|
||||||
|
CRC ^= Data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RxData:
|
||||||
|
{
|
||||||
|
//mRxData[BufPtr++] = Data;
|
||||||
|
mDataBuffer.append(Data);
|
||||||
|
CRC ^= Data;
|
||||||
|
DataCnt++;
|
||||||
|
|
||||||
|
if(DataCnt == RxSize)
|
||||||
|
RxState = RxCRC;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RxCRC:
|
||||||
|
{
|
||||||
|
if(Data != CRC) //Data corruption
|
||||||
|
{
|
||||||
|
ResetRxStateMachine();
|
||||||
|
ret = PROTOCOL_RET_ERROR_BAD_CRC;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mDataBuffer = QByteArray(&mRxData[DATA_START],RxSize);
|
||||||
|
NewFrameReceived(TargetDeviceID,TargetAddress,SenderID,SenderAddress,RxCmd,RxSize,mDataBuffer);
|
||||||
|
ret = PROTOCOL_RET_OK_PACKET_COMPLETE;
|
||||||
|
if(mIsResetManual == false)
|
||||||
|
{
|
||||||
|
ResetRxStateMachine();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ret = PROTOCOL_RET_ERROR_SM_LOGIC;
|
||||||
|
ResetRxStateMachine();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkProtocol::ResetRxStateMachine(void)
|
||||||
|
{
|
||||||
|
RxState = RxHeader;
|
||||||
|
RxSize = 0;
|
||||||
|
SenderID = 0;
|
||||||
|
SenderAddress = 0;
|
||||||
|
TargetAddress = 0;
|
||||||
|
TargetDeviceID = 0;
|
||||||
|
RxCmd = 0;
|
||||||
|
memset(mRxData,0,sizeof(mRxData));
|
||||||
|
DataCnt = 0;
|
||||||
|
BufPtr = 0;
|
||||||
|
CRC = 0;
|
||||||
|
Flags = 0;
|
||||||
|
mDataBuffer.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkProtocol::PrepareForNewPacket()
|
||||||
|
{
|
||||||
|
ResetRxStateMachine();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetworkProtocol::AnalyzeRxBuffer(QByteArray Buffer)
|
||||||
|
{
|
||||||
|
int ret = PROTOCOL_RET_ERROR_EMPTY_BUFFER;
|
||||||
|
for(int i = 0; i < Buffer.size(); i++)
|
||||||
|
{
|
||||||
|
ret = RxStateMachine(Buffer.at(i));
|
||||||
|
if(ret != PROTOCOL_RET_OK_PACKET_INCOMPLETE)
|
||||||
|
{
|
||||||
|
if(ret == PROTOCOL_RET_OK_BAD_HEADER)
|
||||||
|
{
|
||||||
|
qDebug("Protocol Bad header");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkProtocol::SetManualPacketReset(bool Manual)
|
||||||
|
{
|
||||||
|
mIsResetManual = Manual;
|
||||||
|
}
|
||||||
92
Sources/NetworkProtocol.h
Normal file
92
Sources/NetworkProtocol.h
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#ifndef NETWORKPROTOCOL_H
|
||||||
|
#define NETWORKPROTOCOL_H
|
||||||
|
|
||||||
|
#define USE_BYTEARRAY_IN_SEND
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include "ProtocolDefs.h"
|
||||||
|
#include "AbstractNetworkInterface.h"
|
||||||
|
#include <QByteArray>
|
||||||
|
|
||||||
|
class CNetworkProtocol
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CNetworkProtocol();
|
||||||
|
~CNetworkProtocol();
|
||||||
|
QByteArray GetTxPacket(unsigned char MessageID, unsigned char Flags, const char *Data, int Size, unsigned char Address, unsigned char ID, unsigned char SenderDevice = ID_SMS_CLIENT, unsigned char SenderAddress = 1);
|
||||||
|
int AnalyzeRxBuffer(QByteArray Buffer);
|
||||||
|
void PrepareForNewPacket();
|
||||||
|
void SetManualPacketReset(bool Manual);
|
||||||
|
|
||||||
|
virtual int NewFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data) = 0;
|
||||||
|
|
||||||
|
enum ProtocolRetValues
|
||||||
|
{
|
||||||
|
PROTOCOL_RET_OK_PACKET_COMPLETE,
|
||||||
|
PROTOCOL_RET_OK_PACKET_INCOMPLETE,
|
||||||
|
PROTOCOL_RET_OK_BAD_HEADER,
|
||||||
|
PROTOCOL_RET_ERROR_INVALID_TARGET_DEVICE,
|
||||||
|
PROTOCOL_RET_ERROR_INVALID_TARGET_ADDRESS,
|
||||||
|
PROTOCOL_RET_ERROR_BAD_CRC,
|
||||||
|
PROTOCOL_RET_ERROR_SM_LOGIC,
|
||||||
|
PROTOCOL_RET_ERROR_EMPTY_BUFFER
|
||||||
|
};
|
||||||
|
|
||||||
|
char ProtocolGetSenderID(){return SenderID;}
|
||||||
|
char ProtocolGetSenderAddress(){return SenderAddress;}
|
||||||
|
int ProtocolGetCmd(){return RxCmd;}
|
||||||
|
int ProtocolGetDataSize(){return RxSize;}
|
||||||
|
QByteArray ProtocolGetData(){return mDataBuffer;}
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ResetRxStateMachine();
|
||||||
|
unsigned char CalcCRC(char *Buffer, int Size);
|
||||||
|
// int TxData(unsigned char MessageID,unsigned char Flags,unsigned char *Data,int Size, unsigned char Address,unsigned char ID);
|
||||||
|
|
||||||
|
int RxStateMachine(unsigned char Data);
|
||||||
|
|
||||||
|
//State Machine states
|
||||||
|
enum States
|
||||||
|
{
|
||||||
|
Initialization,
|
||||||
|
RxHeader,
|
||||||
|
RxID,
|
||||||
|
RxAdd,
|
||||||
|
RxMyID,
|
||||||
|
RxMyAddress,
|
||||||
|
RxFlags,
|
||||||
|
RxCMD,
|
||||||
|
RxSize1,
|
||||||
|
RxSize2,
|
||||||
|
RxSize3,
|
||||||
|
RxSize4,
|
||||||
|
RxData,
|
||||||
|
RxCRC
|
||||||
|
};
|
||||||
|
|
||||||
|
bool mIsResetManual;
|
||||||
|
|
||||||
|
|
||||||
|
char *RxBuff;
|
||||||
|
char mRxData[MAX_MESSAGE_SIZE+10];
|
||||||
|
|
||||||
|
int RxState;
|
||||||
|
int RxSize;
|
||||||
|
char SenderID;
|
||||||
|
char SenderAddress;
|
||||||
|
int RxCmd;
|
||||||
|
int TargetDeviceID;
|
||||||
|
int TargetAddress;
|
||||||
|
int DataCnt;
|
||||||
|
int BufPtr;
|
||||||
|
unsigned char CRC;
|
||||||
|
unsigned char Flags;
|
||||||
|
|
||||||
|
unsigned char State;
|
||||||
|
|
||||||
|
QByteArray mDataBuffer;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NETWORKPROTOCOL_H
|
||||||
146
Sources/ProgramSettings.cpp
Normal file
146
Sources/ProgramSettings.cpp
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
#include "ProgramSettings.h"
|
||||||
|
|
||||||
|
CProgramSettings::CProgramSettings()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int CProgramSettings::LoadSettings(CSettings* Settings)
|
||||||
|
{
|
||||||
|
QFile* SettingsFile = new QFile("./Configuration/Settings.mcs");
|
||||||
|
if(SettingsFile)
|
||||||
|
{
|
||||||
|
if(SettingsFile->open(QIODevice::ReadOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
LoadDefaultSettings(Settings);
|
||||||
|
SaveSettings(Settings);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadDefaultSettings(Settings);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream * InputStream = new QDataStream(SettingsFile);
|
||||||
|
|
||||||
|
quint32 MagicNbr;// = 0xBAADCAFE;
|
||||||
|
|
||||||
|
*InputStream >> MagicNbr;
|
||||||
|
|
||||||
|
if(MagicNbr != 0xBAADCAFE)
|
||||||
|
{
|
||||||
|
LoadDefaultSettings(Settings);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*InputStream >> *Settings;
|
||||||
|
|
||||||
|
SettingsFile->close();
|
||||||
|
delete SettingsFile;
|
||||||
|
delete InputStream;
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProgramSettings::LoadDefaultSettings(CSettings *Settings)
|
||||||
|
{
|
||||||
|
Settings->mVoipMSSettings.mDefaultDID = "555555555";
|
||||||
|
Settings->mVoipMSSettings.mPassword = "Voip.ms Password";
|
||||||
|
Settings->mVoipMSSettings.mUsername = "Voip.ms Username";
|
||||||
|
Settings->mVoipMSSettings.mStartDate = QDate::currentDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CProgramSettings::SaveSettings(CSettings *SettingsData)
|
||||||
|
{
|
||||||
|
QFile* SettingsFile = new QFile("./Configuration/Settings.mcs");
|
||||||
|
if(SettingsFile)
|
||||||
|
{
|
||||||
|
if(SettingsFile->open(QIODevice::WriteOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream * OutputStream = new QDataStream(SettingsFile);
|
||||||
|
|
||||||
|
quint32 MagicNbr = 0xBAADCAFE;
|
||||||
|
|
||||||
|
*OutputStream << MagicNbr;
|
||||||
|
|
||||||
|
*OutputStream << *SettingsData;
|
||||||
|
|
||||||
|
SettingsFile->flush();
|
||||||
|
SettingsFile->close();
|
||||||
|
|
||||||
|
delete SettingsFile;
|
||||||
|
delete OutputStream;
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CSettings &source)
|
||||||
|
{
|
||||||
|
out << source.mVoipMSSettings;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CSettings &dest)
|
||||||
|
{
|
||||||
|
in >> dest.mVoipMSSettings;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CVoipMSSMSSettings &source)
|
||||||
|
{
|
||||||
|
out << source.mDefaultDID
|
||||||
|
<< source.mPassword
|
||||||
|
<< source.mStartDate
|
||||||
|
<< source.mUsername;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CVoipMSSMSSettings &dest)
|
||||||
|
{
|
||||||
|
in >> dest.mDefaultDID
|
||||||
|
>> dest.mPassword
|
||||||
|
>> dest.mStartDate
|
||||||
|
>> dest.mUsername;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
CVoipMSSMSSettings& CVoipMSSMSSettings::operator=(const CVoipMSSMSSettings *source)
|
||||||
|
{
|
||||||
|
if(source == this)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->mDefaultDID = source->mDefaultDID;
|
||||||
|
this->mPassword = source->mPassword;
|
||||||
|
this->mStartDate = source->mStartDate;
|
||||||
|
this->mUsername = source->mUsername;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSettings& CSettings::operator =(const CSettings &source)
|
||||||
|
{
|
||||||
|
if(this == &source)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
this->mVoipMSSettings = source.mVoipMSSettings;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
54
Sources/ProgramSettings.h
Normal file
54
Sources/ProgramSettings.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#ifndef CPROGRAMSETTINGS_H
|
||||||
|
#define CPROGRAMSETTINGS_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QFile>
|
||||||
|
#include <QDate>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
class CVoipMSSMSSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString mUsername;
|
||||||
|
QString mPassword;
|
||||||
|
QDate mStartDate;
|
||||||
|
QString mDefaultDID;
|
||||||
|
|
||||||
|
CVoipMSSMSSettings &operator=(const CVoipMSSMSSettings *source);
|
||||||
|
|
||||||
|
};
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CVoipMSSMSSettings &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CVoipMSSMSSettings &dest);
|
||||||
|
|
||||||
|
|
||||||
|
class CSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CVoipMSSMSSettings mVoipMSSettings;
|
||||||
|
|
||||||
|
CSettings &operator=(const CSettings &source);
|
||||||
|
};
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CSettings &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CSettings &dest);
|
||||||
|
|
||||||
|
class CProgramSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CProgramSettings();
|
||||||
|
unsigned int LoadSettings(CSettings*);
|
||||||
|
unsigned int SaveSettings(CSettings *SettingsData);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void LoadDefaultSettings(CSettings* Settings);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CPROGRAMSETTINGS_H
|
||||||
186
Sources/ProtocolDefs.h
Normal file
186
Sources/ProtocolDefs.h
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
Project: Automatic cat feeder
|
||||||
|
Date: march 19 2006
|
||||||
|
Author: Jean-François Martel
|
||||||
|
Target: PIC 18F252
|
||||||
|
Compiler: Microchip mcc18
|
||||||
|
Filename: Protocol.h
|
||||||
|
|
||||||
|
File description: Communication protocol implementation.
|
||||||
|
|
||||||
|
|
||||||
|
jean-francois.martel@polymtl.ca
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef PROTOCOLDEFS_H
|
||||||
|
#define PROTOCOLDEFS_H
|
||||||
|
|
||||||
|
//Protocol buffer specific definitionsazsdf
|
||||||
|
|
||||||
|
#define MAX_MESSAGE_SIZE 0xFFFF
|
||||||
|
|
||||||
|
#define FRAME_HEADER 0x8A
|
||||||
|
#define DATA_START 11
|
||||||
|
#define ACK 0xA3
|
||||||
|
#define NAK 0x90
|
||||||
|
#define BROADCAST_VALUE 0xFF
|
||||||
|
|
||||||
|
enum eFrameIndex
|
||||||
|
{
|
||||||
|
FRAME_HEADER_INDEX,
|
||||||
|
FRAME_SENDER_ID_INDEX,
|
||||||
|
FRAME_SENDER_ADDRESS_INDEX,
|
||||||
|
FRAME_DEST_ID_INDEX,
|
||||||
|
FRAME_DEST_ADDRESS_INDEX,
|
||||||
|
FRAME_FLAGS_INDEX,
|
||||||
|
FRAME_COMMAND_INDEX,
|
||||||
|
FRAME_SIZE1_INDEX,
|
||||||
|
FRAME_SIZE2_INDEX,
|
||||||
|
FRAME_DATA_INDEX
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DEVICES_IDS
|
||||||
|
{
|
||||||
|
ID_MASTER, //Master Controller
|
||||||
|
ID_CONSOLE, //LCD Console
|
||||||
|
ID_PC, //PC
|
||||||
|
ID_AV_MUX, //Audio Video Multiplexer
|
||||||
|
ID_IR_REMOTE, //Infra red transmitter
|
||||||
|
ID_DEADBOLT,
|
||||||
|
ID_RECEIVER_AMP,
|
||||||
|
ID_SMS_CLIENT,
|
||||||
|
ID_ETHERNET_VIRTUAL,
|
||||||
|
ID_SPRINKLER_DEVICE,
|
||||||
|
ID_SPRINKLER_INTERFACE,
|
||||||
|
ID_DEADBOLT_INTERFACE,
|
||||||
|
ID_NB_DEVICE_ID
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Commands definitions
|
||||||
|
|
||||||
|
enum MASTER_CMD
|
||||||
|
{
|
||||||
|
RX_MASTER_GET_STATUS,
|
||||||
|
TX_MASTER_STATUS,
|
||||||
|
TX_MASTER_ACK,
|
||||||
|
RX_MASTER_SET_NET_INFO,
|
||||||
|
RX_MASTER_GET_NET_INFO,
|
||||||
|
TX_MASTER_NET_INFO,
|
||||||
|
RX_MASTER_SEND_DEVICE_CMD,
|
||||||
|
TX_MASTER_SEND_DEVICE_CMD_ACK,
|
||||||
|
RX_MASTER_SET_WEATHER_INFO,
|
||||||
|
TX_MASTER_SET_WEATHER_INFO_ACK,
|
||||||
|
RX_MASTER_SET_MAIL_MSG,
|
||||||
|
TX_MASTER_SET_MAIL_MSG_ACK,
|
||||||
|
RX_MASTER_NEW_OUTLOOK_EMAILS,
|
||||||
|
TX_MASTER_NEW_OUTLOOK_EMAILS_ACK,
|
||||||
|
RX_MASTER_TODAYS_EVENTS,
|
||||||
|
TX_MASTER_TODAYS_EVENTS_ACK
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//CONSOLE
|
||||||
|
enum CONSOLE_CMD
|
||||||
|
{
|
||||||
|
RX_CONSOLE_GET_STATUS,
|
||||||
|
TX_CONSOLE_STATUS,
|
||||||
|
TX_CONSOLE_ACK,
|
||||||
|
RX_START_CALIBRATION,
|
||||||
|
RX_GET_CONSOLE_EVENT_MSG,
|
||||||
|
TX_CONSOLE_EVENT_MSG,
|
||||||
|
RX_CONSOLE_SHOW_CALLER_ID,
|
||||||
|
RX_SET_TIME,
|
||||||
|
RX_SET_WEATHER,
|
||||||
|
RX_SEND_NEW_MAIL_MSG,
|
||||||
|
RX_SEND_NEW_MAIL_MSG_ACK,
|
||||||
|
RX_NEW_OUTLOOK_EMAILS,
|
||||||
|
TX_NEW_OUTLOOK_EMAILS_ACK,
|
||||||
|
RX_TODAYS_EVENTS,
|
||||||
|
TX_TODAYS_EVENTS_ACK,
|
||||||
|
LAST_CONSOLE_CMD
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum IR_REMOTE_CMDS
|
||||||
|
{
|
||||||
|
TX_IR_REMOTE_ACK = 1,
|
||||||
|
RX_GET_STATUS,
|
||||||
|
TX_REMOTE_STATUS,
|
||||||
|
RX_TRANSMIT_CMD,
|
||||||
|
RX_LEARN_IR_CMD,
|
||||||
|
TX_LEARN_IR_CMD_FINISHED,
|
||||||
|
RX_GET_IR_DATA,
|
||||||
|
TX_SEND_IR_DATA,
|
||||||
|
RX_SET_IR_CMD,
|
||||||
|
RX_SET_IR_DATA,
|
||||||
|
RX_GET_IR_CMD,
|
||||||
|
TX_SEND_IR_CMD,
|
||||||
|
MAX_IR_REMOTE_CMD
|
||||||
|
};
|
||||||
|
|
||||||
|
//The SMS remote interface commands
|
||||||
|
enum SMS_CLIENT_CMDS
|
||||||
|
{
|
||||||
|
SMS_CLIENT_DEVICE_ACK = 1,
|
||||||
|
SMS_CLIENT_DEVICE_STATUS_REQUEST,
|
||||||
|
SMS_CLIENT_DEVICE_STATUS_RESPONSE,
|
||||||
|
SMS_CLIENT_DEVICE_DID_INFO_REQUEST,
|
||||||
|
SMS_CLIENT_DEVICE_DID_INFO_RESPONSE,
|
||||||
|
SMS_CLIENT_DEVICE_GET_ALL_MSG_REQUEST,
|
||||||
|
SMS_CLIENT_DEVICE_GET_ALL_MSG_RESPONSE,
|
||||||
|
SMS_CLIENT_DEVICE_NEW_MSG_NOTIFICATION,
|
||||||
|
SMS_CLIENT_DEVICE_SEND_SMS_REQUEST,
|
||||||
|
SMS_CLIENT_DEVICE_SEND_SMS_ACK,
|
||||||
|
SMS_CLIENT_DEVICE_GET_CONTACTS_REQUEST,
|
||||||
|
SMS_CLIENT_DEVICE_GET_CONTACTS_RESPONSE,//12
|
||||||
|
SMS_CLIENT_DEVICE_CONTACTS_CHANGED_NOTIFICATION,
|
||||||
|
|
||||||
|
SMS_CLIENT_DEVICE_MAX_MSG
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//The actual deadbolt device commands
|
||||||
|
enum DEADBOLT_CMDS
|
||||||
|
{
|
||||||
|
DEADBOLT_DEVICE_ACK = 1,
|
||||||
|
DEADBOLT_DEVICE_STATUS_REQUEST,
|
||||||
|
DEADBOLT_DEVICE_STATUS_RESPONSE,
|
||||||
|
|
||||||
|
MAX_DEADBOLT_DEVICE_CMD
|
||||||
|
};
|
||||||
|
|
||||||
|
//The actual sprinkler module device commands
|
||||||
|
enum SPRINKLER_DEVICE_CMDS
|
||||||
|
{
|
||||||
|
SPRINKLER_DEVICE_ACK = 1,
|
||||||
|
SPRINKLER_DEVICE_STATUS_REQUEST,
|
||||||
|
SPRINKLER_DEVICE_STATUS_RESPONSE,
|
||||||
|
|
||||||
|
MAX_SPRINKLER_DEVICE_CMD
|
||||||
|
};
|
||||||
|
|
||||||
|
//The sprinkler interface commands
|
||||||
|
enum SPRINKLER_INTERFACE_CMDS
|
||||||
|
{
|
||||||
|
SPRINKLER_INTERFACE_ACK = 1,
|
||||||
|
SPRINKLER_INTERFACE_STATUS_REQUEST,
|
||||||
|
SPRINKLER_INTERFACE_STATUS_RESPONSE,
|
||||||
|
|
||||||
|
MAX_SPRINKLER_INTERFACE_CMD
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum ETHERNET_NETWORK_VIRTUAL_CMDS
|
||||||
|
{
|
||||||
|
ETH_NETWK_DEVICE_INFO_REQUEST = 0xD0,
|
||||||
|
ETH_NETWK_DEVICE_INFO_RESPONSE,
|
||||||
|
ETH_NETWK_SET_DEVICE_INFO_ACK,
|
||||||
|
ETH_NETWK_CONNECTION_REFUSED,
|
||||||
|
|
||||||
|
MAX_ETHERNET_NETWORK_VIRTUAL_CMDS
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
107
Sources/SMSClient/Contact.cpp
Normal file
107
Sources/SMSClient/Contact.cpp
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
#include "Contact.h"
|
||||||
|
|
||||||
|
CContact::CContact(QString ContactNbr, QString ContactName, QPixmap *Picture)
|
||||||
|
{
|
||||||
|
|
||||||
|
mRAWContactNbr = ContactNbr;
|
||||||
|
mContactNumber = ContactNbr;
|
||||||
|
mContactNumber.insert(0,'(');
|
||||||
|
mContactNumber.insert(4,") ");
|
||||||
|
mContactNumber.insert(9,'-');
|
||||||
|
|
||||||
|
mContactName = ContactName;
|
||||||
|
if(mContactName == "")
|
||||||
|
{
|
||||||
|
mContactName = mContactNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(Picture == 0)
|
||||||
|
{
|
||||||
|
mContactPicture = QPixmap("./Ico/contact.png");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(Picture->isNull())
|
||||||
|
{
|
||||||
|
mContactPicture = QPixmap("./Ico/contact.png");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mContactPicture = QPixmap(*Picture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CContact::CContact()
|
||||||
|
{
|
||||||
|
mContactNumber="INVALID";
|
||||||
|
mContactPicture = QPixmap("./Ico/contact.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
CContact::~CContact()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CContact::SetContactImage(QString FilePath)
|
||||||
|
{
|
||||||
|
mContactPicture = QPixmap(FilePath);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator ==(const CContact& left, const CContact& right)
|
||||||
|
{
|
||||||
|
if(left.mRAWContactNbr == right.mRAWContactNbr)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool operator !=(const CContact& left, const CContact& right)
|
||||||
|
{
|
||||||
|
return !(left==right);
|
||||||
|
}
|
||||||
|
|
||||||
|
CContact & CContact::operator=(const CContact source)
|
||||||
|
{
|
||||||
|
if(&source == this)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->mRAWContactNbr = source.mRAWContactNbr;
|
||||||
|
this->mContactName = source.mContactName;
|
||||||
|
this->mContactNumber = source.mContactNumber;
|
||||||
|
this->mContactPicture = source.mContactPicture;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CContact &source)
|
||||||
|
{
|
||||||
|
out << source.mContactName
|
||||||
|
<< source.mContactNumber
|
||||||
|
<< source.mContactPicture
|
||||||
|
<< source.mRAWContactNbr;
|
||||||
|
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CContact &dest)
|
||||||
|
{
|
||||||
|
in >> dest.mContactName
|
||||||
|
>> dest.mContactNumber
|
||||||
|
>> dest.mContactPicture
|
||||||
|
>> dest.mRAWContactNbr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
29
Sources/SMSClient/Contact.h
Normal file
29
Sources/SMSClient/Contact.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef CCONTACT_H
|
||||||
|
#define CCONTACT_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
|
class CContact
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CContact(QString ContactNbr, QString ContactName = "", QPixmap *Picture = 0);
|
||||||
|
CContact();
|
||||||
|
virtual ~CContact();
|
||||||
|
|
||||||
|
int SetContactImage(QString FilePath);
|
||||||
|
|
||||||
|
QString mContactName;
|
||||||
|
QPixmap mContactPicture;
|
||||||
|
QString mContactNumber, mRAWContactNbr;
|
||||||
|
|
||||||
|
CContact &operator=(const CContact source);
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator==(const CContact& left, const CContact& right);
|
||||||
|
bool operator!=(const CContact& left, const CContact& right);
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CContact &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CContact &dest);
|
||||||
|
#endif // CCONTACT_H
|
||||||
168
Sources/SMSClient/ContactRepository.cpp
Normal file
168
Sources/SMSClient/ContactRepository.cpp
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
#include "ContactRepository.h"
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
CContactRepository::CContactRepository()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//int CContactRepository::LoadContacts()
|
||||||
|
//{
|
||||||
|
// QFile* ContactsFile = new QFile("./Configuration/Contacts.mcc");
|
||||||
|
// if(ContactsFile)
|
||||||
|
// {
|
||||||
|
// if(ContactsFile->open(QIODevice::ReadOnly | QIODevice::Unbuffered) == false)
|
||||||
|
// {
|
||||||
|
// if(ContactsFile->open(QIODevice::WriteOnly | QIODevice::Unbuffered) == true)
|
||||||
|
// {
|
||||||
|
// mContactsList.clear();
|
||||||
|
// SaveContacts(); //create an empty file...
|
||||||
|
// }
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// mContactsList.clear();
|
||||||
|
|
||||||
|
// QDataStream * InputStream = new QDataStream(ContactsFile);
|
||||||
|
|
||||||
|
// quint32 MagicNbr;// = 0xBAADCAFE;
|
||||||
|
// quint32 NbEntries;
|
||||||
|
|
||||||
|
// *InputStream >> MagicNbr;
|
||||||
|
|
||||||
|
// if(MagicNbr != 0xDEADBEEF)
|
||||||
|
// {
|
||||||
|
// return RET_ERROR;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// *InputStream >> NbEntries;
|
||||||
|
|
||||||
|
// for(unsigned int i = 0; i < NbEntries; i++)
|
||||||
|
// {
|
||||||
|
// CContact NewContact;
|
||||||
|
// *InputStream >> NewContact;
|
||||||
|
// mContactsList.append(NewContact);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// qDebug("Loaded %d contacts",mContactsList.size());
|
||||||
|
// ContactsFile->close();
|
||||||
|
// delete ContactsFile;
|
||||||
|
// delete InputStream;
|
||||||
|
|
||||||
|
// return mContactsList.size();
|
||||||
|
//}
|
||||||
|
|
||||||
|
int CContactRepository::SetContacts(QList<CContact> *ContactsList)
|
||||||
|
{
|
||||||
|
mContactsList.clear();
|
||||||
|
mContactsList = *ContactsList;
|
||||||
|
|
||||||
|
return mContactsList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
CContact * CContactRepository::FindContact(QString ContactRawNumber)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < mContactsList.size(); i++)
|
||||||
|
{
|
||||||
|
if(mContactsList.at(i).mRAWContactNbr == ContactRawNumber)
|
||||||
|
{
|
||||||
|
return &mContactsList[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CContactRepository::AddContact(CContact Contact)
|
||||||
|
{
|
||||||
|
|
||||||
|
for(int i = 0; i < mContactsList.size(); i++)
|
||||||
|
{
|
||||||
|
if(mContactsList.at(i) == Contact)
|
||||||
|
{
|
||||||
|
mContactsList[i] = Contact;
|
||||||
|
//SaveContacts();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mContactsList.append(Contact);
|
||||||
|
// SaveContacts();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CContactRepository::DeleteContact(int index)
|
||||||
|
{
|
||||||
|
if(index < 0 || index >= mContactsList.size())
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
mContactsList.takeAt(index);
|
||||||
|
// SaveContacts();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CContactRepository::GetContact(int index,CContact& Contact)
|
||||||
|
{
|
||||||
|
if(index < 0 || index >= mContactsList.size())
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Contact = mContactsList.at(index);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
CContact *CContactRepository::GetContactPtr(int index)
|
||||||
|
{
|
||||||
|
if(index < 0 || index >= mContactsList.size())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &mContactsList[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
//int CContactRepository::SaveContacts()
|
||||||
|
//{
|
||||||
|
// QFile* ContactsFile = new QFile("./Configuration/Contacts.mcc");
|
||||||
|
// if(ContactsFile)
|
||||||
|
// {
|
||||||
|
// if(ContactsFile->open(QIODevice::WriteOnly | QIODevice::Unbuffered | QIODevice::Truncate) == false)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// QDataStream * InputStream = new QDataStream(ContactsFile);
|
||||||
|
|
||||||
|
// quint32 MagicNbr = 0xDEADBEEF;
|
||||||
|
|
||||||
|
// *InputStream << MagicNbr;
|
||||||
|
// *InputStream << mContactsList.size();
|
||||||
|
|
||||||
|
// for(int i = 0; i < mContactsList.size(); i++)
|
||||||
|
// {
|
||||||
|
// *InputStream << mContactsList.at(i);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// ContactsFile->close();
|
||||||
|
// delete ContactsFile;
|
||||||
|
// delete InputStream;
|
||||||
|
|
||||||
|
// qDebug("SAved %d contacts",mContactsList.size());
|
||||||
|
|
||||||
|
// return mContactsList.size();
|
||||||
|
//}
|
||||||
27
Sources/SMSClient/ContactRepository.h
Normal file
27
Sources/SMSClient/ContactRepository.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef CCONTACTREPOSITORY_H
|
||||||
|
#define CCONTACTREPOSITORY_H
|
||||||
|
|
||||||
|
#include "Contact.h"
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
|
||||||
|
class CContactRepository
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CContactRepository();
|
||||||
|
|
||||||
|
// int LoadContacts();
|
||||||
|
// int SaveContacts();
|
||||||
|
int SetContacts(QList<CContact> *ContactsList);
|
||||||
|
int AddContact(CContact Contact);
|
||||||
|
QList<CContact> *GetContacts(){return &mContactsList;}
|
||||||
|
int GetContact(int index, CContact &Contact);
|
||||||
|
CContact *GetContactPtr(int index);
|
||||||
|
CContact *FindContact(QString ContactRawNumber);
|
||||||
|
int DeleteContact(int index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<CContact> mContactsList;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CCONTACTREPOSITORY_H
|
||||||
198
Sources/SMSClient/SMSClient.cpp
Normal file
198
Sources/SMSClient/SMSClient.cpp
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
#include "SMSClient.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CSMSClient::CSMSClient(CSMSGui *GuiHandle, CVoipMSSMSSettings *ProgramSettings)
|
||||||
|
{
|
||||||
|
qDebug("Creation...");
|
||||||
|
mSMSDatabase.mProgramHandle = this;
|
||||||
|
mGuiHandle = GuiHandle;
|
||||||
|
mGuiHandle->mProgramHandle = this;
|
||||||
|
mGuiHandle->mSMSDatabase = &mSMSDatabase;
|
||||||
|
mSettings = ProgramSettings;
|
||||||
|
|
||||||
|
// mSystemTrayManager = new CSystemTrayManager;
|
||||||
|
// mSystemTrayManager->mProgramHandle = this;
|
||||||
|
// mSettingsWindow = new CSettingsWindow();
|
||||||
|
// mSettingsWindow->mProgramHandle = this;
|
||||||
|
//mMainPanel = new Panel;
|
||||||
|
// mMasterCtrlIF = new CMasterCtrlInterface();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMSClient::~CSMSClient()
|
||||||
|
{
|
||||||
|
// delete mSystemTrayManager;
|
||||||
|
// delete mSettingsWindow;
|
||||||
|
// delete mMainPanel;
|
||||||
|
// delete mMasterCtrlIF;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSClient::Start()
|
||||||
|
{
|
||||||
|
qDebug("Started!");
|
||||||
|
mMasterCtrlIF = new CSMSMasterCtrlInterface(this);
|
||||||
|
mSMSDatabase.mContactRepository = &mContactRepository;
|
||||||
|
|
||||||
|
mMasterCtrlIF->ConnectToMasterCtrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSClient::SetAllMsgsDatabase(QString DID, QList<CSMSMessage> *MessagesList)
|
||||||
|
{
|
||||||
|
if(mSMSDatabase.SetAllMessages(DID,MessagesList) == RET_OK)
|
||||||
|
{
|
||||||
|
mGuiHandle->FullConversationsUpdate();
|
||||||
|
// mMainPanel->mConversationsWindow->FullConversationsUpdate();
|
||||||
|
// mMainPanel->mConversationWindow->hide();
|
||||||
|
}
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSClient::SetDIDDatabase(QString DID)
|
||||||
|
{
|
||||||
|
mSMSDatabase.SetDID(DID);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSClient::NewMessagesEvent(QList<CSMSMessage> *MessagesList)
|
||||||
|
{
|
||||||
|
mSMSDatabase.SetNewMessages("",MessagesList);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSClient::SetContacts(QList<CContact> *ContactsList)
|
||||||
|
{
|
||||||
|
mContactRepository.SetContacts(ContactsList);
|
||||||
|
mSMSDatabase.ContactsRepositoryChanged();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//unsigned int CSMSClient::QuitApplicationRequest()
|
||||||
|
//{
|
||||||
|
|
||||||
|
// QApplication::exit(69);
|
||||||
|
// return RET_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//unsigned int CSMSClient::ShowSettingsWindowRequest()
|
||||||
|
//{
|
||||||
|
// mSettingsWindow->show();
|
||||||
|
// return RET_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//unsigned int CSMSClient::SaveSettings(CSettings *Settings)
|
||||||
|
//{
|
||||||
|
// CSettings toto;
|
||||||
|
// toto = *Settings;
|
||||||
|
// mSMSClientSettings = toto;
|
||||||
|
// mSettingsManager.SaveSettings(&mSMSClientSettings);
|
||||||
|
|
||||||
|
// return RET_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//unsigned int CSMSClient::SettingsWindowClosed()
|
||||||
|
//{
|
||||||
|
|
||||||
|
// return RET_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//int CSMSClient::AppToggle()
|
||||||
|
//{
|
||||||
|
//// if(mMainPanel->mConversationWindow->isVisible())
|
||||||
|
//// {
|
||||||
|
//// mMainPanel->mConversationWindow->hide();
|
||||||
|
|
||||||
|
//// }
|
||||||
|
//// else if(mMainPanel->mConversationsWindow->isVisible())
|
||||||
|
//// {
|
||||||
|
//// mMainPanel->mConversationsWindow->hide();
|
||||||
|
//// }
|
||||||
|
//// else
|
||||||
|
//// {
|
||||||
|
//// mMainPanel->mConversationsWindow->show();
|
||||||
|
//// }
|
||||||
|
|
||||||
|
// return RET_OK;
|
||||||
|
//}
|
||||||
|
//int CSMSClient::AppPosChanged(int NewPosX, int NewPosY)
|
||||||
|
//{
|
||||||
|
//// mMainPanel->mConversationsWindow->setPos(50,50);
|
||||||
|
//// mMainPanel->mConversationWindow->setPos(50,50);
|
||||||
|
// return RET_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
int CSMSClient::ShowConversation(QString Contact)
|
||||||
|
{
|
||||||
|
CSMSConversation* Conversation;
|
||||||
|
Conversation = mSMSDatabase.GetConversation(Contact);
|
||||||
|
|
||||||
|
if(Conversation == 0)
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mMainPanel->mConversationWindow->SetConversation(Conversation);
|
||||||
|
|
||||||
|
// mMainPanel->mConversationsWindow->hide();
|
||||||
|
// mMainPanel->mConversationWindow->show();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//int CSMSClient::CloseConversationsWindow()
|
||||||
|
//{
|
||||||
|
//// mMainPanel->mConversationsWindow->hide();
|
||||||
|
// return RET_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//int CSMSClient::CloseConversationWindow(CConversationWindow *Window)
|
||||||
|
//{
|
||||||
|
// Q_UNUSED(Window)
|
||||||
|
|
||||||
|
//// mMainPanel->mConversationsWindow->FullConversationsUpdate();
|
||||||
|
//// mMainPanel->mConversationWindow->hide();
|
||||||
|
//// mMainPanel->mConversationsWindow->show();
|
||||||
|
|
||||||
|
// return RET_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
int CSMSClient::SendSMSMessage(CSMSMessage Message)
|
||||||
|
{
|
||||||
|
mMasterCtrlIF->SendSMS(Message);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSClient::NewMessageNotification(CSMSConversation *Conversation, int MessageIndex)
|
||||||
|
{
|
||||||
|
// if(mMainPanel->mConversationWindow->NewMessageNotification(Conversation,MessageIndex) == true)
|
||||||
|
// {
|
||||||
|
// mSMSDatabase.SetConversationAsRead(Conversation);
|
||||||
|
// }
|
||||||
|
// mMainPanel->mConversationsWindow->UpdateConversation(Conversation);
|
||||||
|
mGuiHandle->NewMessageNotification(Conversation,MessageIndex);
|
||||||
|
|
||||||
|
MessageCountChangeNotification(mSMSDatabase.GetNbUnreadMsgs());
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSClient::SyncConversations()
|
||||||
|
{
|
||||||
|
// mMainPanel->mConversationsWindow->FullConversationsUpdate();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSClient::MessageCountChangeNotification(int MsgCount)
|
||||||
|
{
|
||||||
|
// mMainPanel->mAppIconWidget->SetNewMsgCount(MsgCount);
|
||||||
|
mTrayIconMgr->NewSMSMessagesPendingCount(MsgCount);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//int CSMSClient::NewConversationAddedToDatabase(CSMSConversation *Conversation)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
77
Sources/SMSClient/SMSClient.h
Normal file
77
Sources/SMSClient/SMSClient.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#ifndef MASTERCTRL_H
|
||||||
|
#define MASTERCTRL_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include "SystemTrayManager.h"
|
||||||
|
#include "SettingsWindow.h"
|
||||||
|
#include "ProgramSettings.h"
|
||||||
|
//#include "AppIconWidget.h"
|
||||||
|
//#include "MainPanel.h"
|
||||||
|
#include "SMSMasterCtrlInterface.h"
|
||||||
|
#include "SMSDatabase.h"
|
||||||
|
#include "ContactRepository.h"
|
||||||
|
#include "SMSGui.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class CSMSClient : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CSMSClient(CSMSGui *GuiHandle, CVoipMSSMSSettings *ProgramSettings);
|
||||||
|
~CSMSClient();
|
||||||
|
|
||||||
|
void Start(void);
|
||||||
|
// CSystemTrayManager *mSystemTrayManager;
|
||||||
|
// CSettingsWindow *mSettingsWindow;
|
||||||
|
// CProgramSettings mSettingsManager;
|
||||||
|
//Panel *mMainPanel;
|
||||||
|
CSMSMasterCtrlInterface *mMasterCtrlIF;
|
||||||
|
CSMSDatabase mSMSDatabase;
|
||||||
|
CContactRepository mContactRepository;
|
||||||
|
CSMSGui *mGuiHandle;
|
||||||
|
CVoipMSSMSSettings *mSettings;
|
||||||
|
CSystemTrayManager *mTrayIconMgr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// unsigned int QuitApplicationRequest();
|
||||||
|
// unsigned int ShowSettingsWindowRequest();
|
||||||
|
// unsigned int SaveSettings(CSettings *Settings);
|
||||||
|
|
||||||
|
// unsigned int SettingsWindowClosed();
|
||||||
|
|
||||||
|
//AppIconWidget requests
|
||||||
|
// int AppToggle();
|
||||||
|
// int AppPosChanged(int NewPosX, int NewPosY);
|
||||||
|
|
||||||
|
//MasterCtrlIngerface Requests
|
||||||
|
int SetAllMsgsDatabase(QString DID, QList<CSMSMessage> *MessagesList);
|
||||||
|
int SetDIDDatabase(QString DID);
|
||||||
|
int NewMessagesEvent(QList<CSMSMessage> *MessagesList);
|
||||||
|
int SetContacts(QList<CContact> *ContactsList);
|
||||||
|
|
||||||
|
|
||||||
|
//ConversationsWindow requests
|
||||||
|
int ShowConversation(QString Contact);
|
||||||
|
// int CloseConversationsWindow();
|
||||||
|
|
||||||
|
|
||||||
|
//ConversationWindow requests
|
||||||
|
//int CloseConversationWindow(CConversationWindow* Window);
|
||||||
|
int SendSMSMessage(CSMSMessage Message);
|
||||||
|
|
||||||
|
//SMSDatabase requests
|
||||||
|
int NewMessageNotification(CSMSConversation* Conversation, int MessageIndex);
|
||||||
|
// void NewConversationAddedToDatabase(CSMSConversation *Conversation);
|
||||||
|
int SyncConversations();
|
||||||
|
int MessageCountChangeNotification(int MsgCount);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
CSettings mSMSClientSettings;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MASTERCTRL_H
|
||||||
61
Sources/SMSClient/SMSConversation.cpp
Normal file
61
Sources/SMSClient/SMSConversation.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include "SMSConversation.h"
|
||||||
|
|
||||||
|
CSMSConversation::CSMSConversation(CContact ConversationContact)
|
||||||
|
{
|
||||||
|
mConversationContact = ConversationContact;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMSConversation::CSMSConversation()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMSConversation::~CSMSConversation()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < mMessages.size(); i++)
|
||||||
|
{
|
||||||
|
delete mMessages.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
mMessages.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSConversation::InsertNewMessage(CSMSMessage *Message)
|
||||||
|
{
|
||||||
|
mMessages.prepend(Message);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSConversation::InsertMessage(CSMSMessage *Message)
|
||||||
|
{
|
||||||
|
mMessages.append(Message);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
CContact* CSMSConversation::GetConversationContact()
|
||||||
|
{
|
||||||
|
return &mConversationContact;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSConversation::SetConversationContact(CContact *Contact)
|
||||||
|
{
|
||||||
|
mConversationContact = *Contact;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMSMessage* CSMSConversation::GetMostRecentMessage()
|
||||||
|
{
|
||||||
|
if(mMessages.isEmpty())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mMessages.at(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<CSMSMessage*> *CSMSConversation::GetMessages()
|
||||||
|
{
|
||||||
|
return &mMessages;
|
||||||
|
}
|
||||||
27
Sources/SMSClient/SMSConversation.h
Normal file
27
Sources/SMSClient/SMSConversation.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef CSMSCONVERSATION_H
|
||||||
|
#define CSMSCONVERSATION_H
|
||||||
|
|
||||||
|
#include "SMSMessage.h"
|
||||||
|
#include <QList>
|
||||||
|
#include "Contact.h"
|
||||||
|
|
||||||
|
class CSMSConversation
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSMSConversation(CContact ConversationContact);
|
||||||
|
CSMSConversation();
|
||||||
|
~CSMSConversation();
|
||||||
|
|
||||||
|
CContact mConversationContact;
|
||||||
|
QList<CSMSMessage*> mMessages;
|
||||||
|
|
||||||
|
int InsertNewMessage(CSMSMessage *Message);
|
||||||
|
int InsertMessage(CSMSMessage *Message);
|
||||||
|
CContact *GetConversationContact();
|
||||||
|
int SetConversationContact(CContact *Contact);
|
||||||
|
CSMSMessage *GetMostRecentMessage();
|
||||||
|
QList<CSMSMessage*> *GetMessages();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CSMSCONVERSATION_H
|
||||||
204
Sources/SMSClient/SMSDatabase.cpp
Normal file
204
Sources/SMSClient/SMSDatabase.cpp
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
#include "SMSDatabase.h"
|
||||||
|
#include "SMSClient.h"
|
||||||
|
|
||||||
|
CSMSDatabase::CSMSDatabase()
|
||||||
|
{
|
||||||
|
mProgramHandle = 0;
|
||||||
|
mNbUnreadMessages = 0;
|
||||||
|
mConversations.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CSMSDatabase::~CSMSDatabase()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < mConversations.size(); i++)
|
||||||
|
{
|
||||||
|
delete mConversations.at(i);
|
||||||
|
}
|
||||||
|
mConversations.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSDatabase::SetAllMessages(QString DID, QList<CSMSMessage> *MessagesList)
|
||||||
|
{
|
||||||
|
Q_UNUSED(DID)
|
||||||
|
mConversations.clear();
|
||||||
|
mNbUnreadMessages = 0;
|
||||||
|
// SetDID(DID);
|
||||||
|
mContactsHash.clear();
|
||||||
|
|
||||||
|
for(int i = 0; i < MessagesList->size(); i++)
|
||||||
|
{
|
||||||
|
CSMSMessage *CurMsg = new CSMSMessage(MessagesList->at(i));
|
||||||
|
QString ContactNbr = CurMsg->mContact;
|
||||||
|
|
||||||
|
if(mContactsHash.contains(ContactNbr) == true)
|
||||||
|
{
|
||||||
|
int Index = mContactsHash.value(ContactNbr);
|
||||||
|
mConversations.at(Index)->InsertMessage(CurMsg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSMSConversation *NewConversation = new CSMSConversation(CContact(CurMsg->mContact));
|
||||||
|
CContact *Contact = mContactRepository->FindContact(CurMsg->mContact);
|
||||||
|
if(Contact != 0)
|
||||||
|
{
|
||||||
|
NewConversation->SetConversationContact(Contact);
|
||||||
|
}
|
||||||
|
mConversations.append(NewConversation);
|
||||||
|
int Index = mConversations.size()-1;
|
||||||
|
mContactsHash.insert(CurMsg->mContact,Index);
|
||||||
|
mConversations.at(Index)->InsertMessage(CurMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Rx %d Messages",MessagesList->size());
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSDatabase::SetNewMessages(QString DID, QList<CSMSMessage> *MessagesList)
|
||||||
|
{
|
||||||
|
Q_UNUSED(DID)
|
||||||
|
|
||||||
|
bool SyncConversations = false;
|
||||||
|
|
||||||
|
for(int i = 0; i < MessagesList->size(); i++)
|
||||||
|
{
|
||||||
|
CSMSMessage *CurMsg = new CSMSMessage(MessagesList->at(i));
|
||||||
|
QString ContactNbr = CurMsg->mContact;
|
||||||
|
// if(CurMsg->mType == SMS_RECEIVED_TYPE)
|
||||||
|
{
|
||||||
|
mNbUnreadMessages++;
|
||||||
|
CurMsg->mIsRead = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mContactsHash.contains(ContactNbr) == true)
|
||||||
|
{
|
||||||
|
int Index = mContactsHash.value(ContactNbr);
|
||||||
|
mConversations.at(Index)->InsertNewMessage(CurMsg);
|
||||||
|
|
||||||
|
|
||||||
|
mProgramHandle->NewMessageNotification(mConversations.at(Index),0);
|
||||||
|
|
||||||
|
// if(Index != 0)
|
||||||
|
// {
|
||||||
|
// CSMSConversation *Conversation = mConversations.takeAt(Index);
|
||||||
|
// mConversations.prepend(Conversation);
|
||||||
|
// mContactsHash.clear();
|
||||||
|
|
||||||
|
// for(int i = 0; i < mConversations.size(); i++)
|
||||||
|
// {
|
||||||
|
// mContactsHash.insert(mConversations.at(i)->mConversationContact.mRAWContactNbr,i);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// SyncConversations = true;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSMSConversation *NewConversation = new CSMSConversation(CContact(CurMsg->mContact));
|
||||||
|
mConversations.append(NewConversation);
|
||||||
|
int Index = mConversations.size()-1;
|
||||||
|
mContactsHash.insert(CurMsg->mContact,Index);
|
||||||
|
mConversations.at(Index)->InsertNewMessage(CurMsg);
|
||||||
|
|
||||||
|
SyncConversations = true;
|
||||||
|
mProgramHandle->MessageCountChangeNotification(mNbUnreadMessages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SyncConversations)
|
||||||
|
{
|
||||||
|
mProgramHandle->SyncConversations();
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Rx %d New Messages",MessagesList->size());
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<CSMSConversation*>* CSMSDatabase::GetConversations(QString DID)
|
||||||
|
{
|
||||||
|
Q_UNUSED(DID);
|
||||||
|
|
||||||
|
return &mConversations;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMSConversation * CSMSDatabase::GetConversation(QString Contact)
|
||||||
|
{
|
||||||
|
if(mContactsHash.contains(Contact))
|
||||||
|
{
|
||||||
|
return mConversations.at(mContactsHash.value(Contact));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSDatabase::SetDID(QString DID)
|
||||||
|
{
|
||||||
|
mClientDID = DID;
|
||||||
|
|
||||||
|
mFormattedDID = DID;
|
||||||
|
mFormattedDID.insert(0,'(');
|
||||||
|
mFormattedDID.insert(4,") ");
|
||||||
|
mFormattedDID.insert(9,'-');
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSDatabase::SetConversationAsRead(CSMSConversation *Conversation, bool ForceAll)
|
||||||
|
{
|
||||||
|
if(Conversation == 0)
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<CSMSMessage*> *Messages = Conversation->GetMessages();
|
||||||
|
|
||||||
|
for(int i = 0; i < Messages->size(); i++)
|
||||||
|
{
|
||||||
|
if(Messages->at(i)->mIsRead == true)
|
||||||
|
{
|
||||||
|
if(ForceAll == false)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Messages->at(i)->mIsRead = true;
|
||||||
|
// if(Messages->at(i)->mType == SMS_RECEIVED_TYPE)
|
||||||
|
{
|
||||||
|
mNbUnreadMessages--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mProgramHandle->MessageCountChangeNotification(mNbUnreadMessages);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CSMSDatabase::ContactsRepositoryChanged()
|
||||||
|
{
|
||||||
|
CContact *Contact;
|
||||||
|
for(int i = 0; i < mConversations.size(); i++)
|
||||||
|
{
|
||||||
|
Contact = mContactRepository->FindContact(mConversations.at(i)->GetConversationContact()->mRAWContactNbr);
|
||||||
|
if(Contact != 0)
|
||||||
|
{
|
||||||
|
mConversations.at(i)->SetConversationContact(Contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
52
Sources/SMSClient/SMSDatabase.h
Normal file
52
Sources/SMSClient/SMSDatabase.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#ifndef CSMSDATABASE_H
|
||||||
|
#define CSMSDATABASE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "SMSConversation.h"
|
||||||
|
#include "SMSMessage.h"
|
||||||
|
#include "ContactRepository.h"
|
||||||
|
#include <QList>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
|
class CSMSClient;
|
||||||
|
|
||||||
|
|
||||||
|
class CSMSDatabase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum eNewMessageReadStatus
|
||||||
|
{
|
||||||
|
DB_NEW_MSG_READ,
|
||||||
|
DB_NEW_MSG_UNREAD
|
||||||
|
};
|
||||||
|
|
||||||
|
CSMSDatabase();
|
||||||
|
~CSMSDatabase();
|
||||||
|
|
||||||
|
CSMSClient *mProgramHandle;
|
||||||
|
CContactRepository *mContactRepository;
|
||||||
|
|
||||||
|
QList<CSMSConversation*> mConversations;
|
||||||
|
QString mClientDID, mFormattedDID;
|
||||||
|
|
||||||
|
QHash<QString,int> mContactsHash;
|
||||||
|
int mNbUnreadMessages;
|
||||||
|
|
||||||
|
int SetAllMessages(QString DID, QList<CSMSMessage> *MessagesList);
|
||||||
|
int SetNewMessages(QString DID, QList<CSMSMessage> *MessagesList);
|
||||||
|
int SetDID(QString DID);
|
||||||
|
int SetConversationAsRead(CSMSConversation* Conversation, bool ForceAll = false);
|
||||||
|
int ContactsRepositoryChanged();
|
||||||
|
|
||||||
|
QList<CSMSConversation *> *GetConversations(QString DID = "");
|
||||||
|
CSMSConversation* GetConversation(QString Contact);
|
||||||
|
QString GetDID(){return mClientDID;}
|
||||||
|
QString GetFormattedDID(){return mFormattedDID;}
|
||||||
|
int GetNbUnreadMsgs(){return mNbUnreadMessages;}
|
||||||
|
|
||||||
|
// bool SortConversations();
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CSMSDATABASE_H
|
||||||
276
Sources/SMSClient/SMSGui.cpp
Normal file
276
Sources/SMSClient/SMSGui.cpp
Normal file
@ -0,0 +1,276 @@
|
|||||||
|
#include "SMSGui.h"
|
||||||
|
#include "ui_SMSGui.h"
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include "SMSClient.h"
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
CSMSGui::CSMSGui(QWidget *parent) :
|
||||||
|
QWidget(parent)
|
||||||
|
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
mSMSDatabase = 0;
|
||||||
|
mSelectedConversation = 0;
|
||||||
|
mProgramHandle = 0;
|
||||||
|
mCharCounter = 160;
|
||||||
|
mMsgCounter = 0;
|
||||||
|
|
||||||
|
mSMSMessageStatsLabel->setText(QString().sprintf("Nombre de caractères du message %d/160\nNombre de messages à envoyer: %d msg",mCharCounter,mMsgCounter+1));
|
||||||
|
|
||||||
|
// connect(mContactsTreeWidget,SIGNAL(itemActivated(QTreeWidgetItem*,int)),this,SLOT(ConversationSelected(QTreeWidgetItem*,int)));
|
||||||
|
connect(mContactsTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(ConversationClicked(QTreeWidgetItem*,int)));
|
||||||
|
connect(mSMSSendBtn,SIGNAL(clicked(bool)),this,SLOT(SendMsgBtnClicked(bool)));
|
||||||
|
connect(mSMSEdit,SIGNAL(textChanged()),this,SLOT(SMSEditZoneContentsChanged()));
|
||||||
|
|
||||||
|
mSMSEdit->installEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMSGui::~CSMSGui()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CSMSGui::FullConversationsUpdate()
|
||||||
|
{
|
||||||
|
QList<CSMSConversation*> *ConversationsList = mSMSDatabase->GetConversations();
|
||||||
|
|
||||||
|
mContactsTreeWidget->clear();
|
||||||
|
mContactsTreeWidget->setColumnCount(3);
|
||||||
|
mContactsTreeWidget->setIconSize(QSize(25,25));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for(int i = 0; i < ConversationsList->size(); i++)
|
||||||
|
{
|
||||||
|
QFont NewMsgFont;
|
||||||
|
NewMsgFont.setBold(true);
|
||||||
|
|
||||||
|
QTreeWidgetItem *NewContact = new QTreeWidgetItem(mContactsTreeWidget);
|
||||||
|
CSMSConversation *Conversation = ConversationsList->at(i);
|
||||||
|
CSMSMessage *LastMsg = Conversation->GetMostRecentMessage();
|
||||||
|
NewContact->setIcon(0,QIcon(Conversation->GetConversationContact()->mContactPicture));
|
||||||
|
if(LastMsg->mIsRead == false)
|
||||||
|
{
|
||||||
|
NewContact->setFont(1,NewMsgFont);
|
||||||
|
NewContact->setFont(2,NewMsgFont);
|
||||||
|
}
|
||||||
|
NewContact->setText(1,Conversation->GetConversationContact()->mContactName);
|
||||||
|
NewContact->setText(2,Conversation->GetConversationContact()->mContactNumber);
|
||||||
|
// QVariant data = QVariant::fromValue((void*)Conversation);
|
||||||
|
NewContact->setData(0,Qt::UserRole,QVariant::fromValue((void*)Conversation));
|
||||||
|
mContactsTreeWidget->insertTopLevelItem(0,NewContact);
|
||||||
|
}
|
||||||
|
|
||||||
|
mContactsTreeWidget->resizeColumnToContents(0);
|
||||||
|
mContactsTreeWidget->resizeColumnToContents(1);
|
||||||
|
mContactsTreeWidget->resizeColumnToContents(2);
|
||||||
|
mContactsTreeWidget->topLevelItem(0)->setSelected(true);
|
||||||
|
ConversationClicked(mContactsTreeWidget->topLevelItem(0),0);
|
||||||
|
|
||||||
|
|
||||||
|
// mContactsTreeWidget->addTopLevelItem(QTreeWidget());
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSGui::ConversationClicked(QTreeWidgetItem *item, int column)
|
||||||
|
{
|
||||||
|
//qDebug("Clicked %d",column);
|
||||||
|
mSelectedConversation = (CSMSConversation*) item->data(0,Qt::UserRole).value<void*>();
|
||||||
|
QString MessageText;
|
||||||
|
MessageText.clear();
|
||||||
|
|
||||||
|
mConversationText->clear();
|
||||||
|
|
||||||
|
// for(int i = 0; i < Conversation->GetMessages()->size(); i++)
|
||||||
|
for(int i = mSelectedConversation->GetMessages()->size()-1; i >=0; i--)
|
||||||
|
{
|
||||||
|
MessageText.append(mSelectedConversation->GetMessages()->at(i)->mDateTime.toString("yyyy/MM/dd hh:mm - "));
|
||||||
|
|
||||||
|
if(mSelectedConversation->GetMessages()->at(i)->mType == SMS_SENT_TYPE)
|
||||||
|
{
|
||||||
|
MessageText.append("YOU: ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageText.append(mSelectedConversation->GetConversationContact()->mContactName);
|
||||||
|
MessageText.append(": ");
|
||||||
|
}
|
||||||
|
MessageText.append(mSelectedConversation->GetMessages()->at(i)->mMessageText);
|
||||||
|
MessageText.append("\n\r");
|
||||||
|
}
|
||||||
|
|
||||||
|
mConversationText->setText(MessageText);
|
||||||
|
|
||||||
|
QFont font;
|
||||||
|
font.setBold(false);
|
||||||
|
item->setFont(0,font);
|
||||||
|
item->setFont(1,font);
|
||||||
|
item->setFont(2,font);
|
||||||
|
|
||||||
|
QTextCursor cursor( mConversationText->textCursor() );
|
||||||
|
cursor.movePosition( QTextCursor::End );
|
||||||
|
|
||||||
|
QScrollBar *bar = mConversationText->verticalScrollBar();
|
||||||
|
if( bar )
|
||||||
|
{
|
||||||
|
if( !bar->isSliderDown() )
|
||||||
|
bar->setValue( bar->maximum() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mConversationText->ensureCursorVisible();
|
||||||
|
|
||||||
|
mContactPic->setPixmap(mSelectedConversation->GetConversationContact()->mContactPicture.scaled(mContactPic->size()));
|
||||||
|
font.setPointSize(26);
|
||||||
|
mContactName->setFont(font);
|
||||||
|
mContactName->setText(mSelectedConversation->GetConversationContact()->mContactName);
|
||||||
|
|
||||||
|
mSMSDatabase->SetConversationAsRead(mSelectedConversation);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSGui::UpdateDisplayedConversation(int MessageIndex)
|
||||||
|
{
|
||||||
|
if(MessageIndex != -1)
|
||||||
|
{
|
||||||
|
QString MessageText;
|
||||||
|
MessageText = mConversationText->toPlainText();
|
||||||
|
|
||||||
|
MessageText.append(mSelectedConversation->GetMessages()->at(MessageIndex)->mDateTime.toString("yyyy/MM/dd hh:mm - "));
|
||||||
|
|
||||||
|
if(mSelectedConversation->GetMessages()->at(MessageIndex)->mType == SMS_SENT_TYPE)
|
||||||
|
{
|
||||||
|
MessageText.append("YOU: ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageText.append(mSelectedConversation->GetMessages()->at(MessageIndex)->mContact);
|
||||||
|
MessageText.append(": ");
|
||||||
|
}
|
||||||
|
MessageText.append(mSelectedConversation->GetMessages()->at(MessageIndex)->mMessageText);
|
||||||
|
MessageText.append("\n\r");
|
||||||
|
|
||||||
|
mConversationText->setText(MessageText);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QTextCursor cursor( mConversationText->textCursor() );
|
||||||
|
cursor.movePosition( QTextCursor::End );
|
||||||
|
|
||||||
|
QScrollBar *bar = mConversationText->verticalScrollBar();
|
||||||
|
if( bar )
|
||||||
|
{
|
||||||
|
if( !bar->isSliderDown() )
|
||||||
|
bar->setValue( bar->maximum() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mConversationText->ensureCursorVisible();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//void CSMSGui::ConversationSelected(QTreeWidgetItem *item, int column)
|
||||||
|
//{
|
||||||
|
// // qDebug("Selected, %d",column);
|
||||||
|
//}
|
||||||
|
|
||||||
|
int CSMSGui::NewMessageNotification(CSMSConversation *Conversation, int MessageIndex)
|
||||||
|
{
|
||||||
|
if(Conversation == 0)
|
||||||
|
{
|
||||||
|
return NEW_MSG_ERROR_STATUS;
|
||||||
|
}
|
||||||
|
if(mSelectedConversation == Conversation) //the new msg comes from the currently displayed contact conversation
|
||||||
|
{
|
||||||
|
UpdateDisplayedConversation(MessageIndex);
|
||||||
|
mSMSDatabase->SetConversationAsRead(mSelectedConversation);
|
||||||
|
return NEW_MSG_READ_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Find conversation...
|
||||||
|
for(int i = 0; i < mContactsTreeWidget->topLevelItemCount(); i++)
|
||||||
|
{
|
||||||
|
void *data = mContactsTreeWidget->topLevelItem(i)->data(0,Qt::UserRole).value<void*>();
|
||||||
|
if((CSMSConversation*)data == Conversation)
|
||||||
|
{
|
||||||
|
//found it!
|
||||||
|
QFont font;
|
||||||
|
font.setBold(true);
|
||||||
|
mContactsTreeWidget->topLevelItem(i)->setFont(0,font);
|
||||||
|
mContactsTreeWidget->topLevelItem(i)->setFont(1,font);
|
||||||
|
mContactsTreeWidget->topLevelItem(i)->setFont(2,font);
|
||||||
|
return NEW_MSG_UNREAD_STATUS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NEW_MSG_ERROR_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSGui::SendEditMessage()
|
||||||
|
{
|
||||||
|
if(mSelectedConversation == 0)
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString MsgTxt = mSMSEdit->toPlainText();
|
||||||
|
|
||||||
|
if(MsgTxt.isEmpty())
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMSMessage Message;
|
||||||
|
Message.mContact = mSelectedConversation->mConversationContact.mRAWContactNbr;
|
||||||
|
Message.mDID = mSMSDatabase->GetDID();
|
||||||
|
Message.mMessageText = MsgTxt;
|
||||||
|
|
||||||
|
mProgramHandle->SendSMSMessage(Message);
|
||||||
|
mSMSEdit->clear();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSGui::SendMsgBtnClicked(bool checked)
|
||||||
|
{
|
||||||
|
Q_UNUSED(checked)
|
||||||
|
SendEditMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSMSGui::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
{
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
if(keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return)
|
||||||
|
{
|
||||||
|
// qDebug("Ate key press %d", keyEvent->key());
|
||||||
|
SendEditMessage();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// qDebug("Key press %d", keyEvent->key());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// standard event processing
|
||||||
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSGui::SMSEditZoneContentsChanged()
|
||||||
|
{
|
||||||
|
int CurStringCharCount = mSMSEdit->toPlainText().size();
|
||||||
|
if(CurStringCharCount <= 160)
|
||||||
|
{
|
||||||
|
mCharCounter = 160-CurStringCharCount;
|
||||||
|
mMsgCounter = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mMsgCounter = (int)(CurStringCharCount / 160);
|
||||||
|
mCharCounter = 160 - (CurStringCharCount - (mMsgCounter*160));
|
||||||
|
}
|
||||||
|
mSMSMessageStatsLabel->setText(QString().sprintf("Nombre de caractères du message %d/160\nNombre de messages à envoyer: %d msg",mCharCounter,mMsgCounter+1));
|
||||||
|
|
||||||
|
}
|
||||||
49
Sources/SMSClient/SMSGui.h
Normal file
49
Sources/SMSClient/SMSGui.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#ifndef SMSGUI_H
|
||||||
|
#define SMSGUI_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "ui_SMSGui.h"
|
||||||
|
#include "SMSDatabase.h"
|
||||||
|
|
||||||
|
//namespace Ui {
|
||||||
|
//class CSMSGui;
|
||||||
|
//}
|
||||||
|
class CSMSClient;
|
||||||
|
|
||||||
|
enum eNewMessageStatus
|
||||||
|
{
|
||||||
|
NEW_MSG_READ_STATUS,
|
||||||
|
NEW_MSG_UNREAD_STATUS,
|
||||||
|
NEW_MSG_ERROR_STATUS
|
||||||
|
};
|
||||||
|
|
||||||
|
class CSMSGui : public QWidget, private Ui::CSMSGui
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CSMSGui(QWidget *parent = 0);
|
||||||
|
~CSMSGui();
|
||||||
|
|
||||||
|
int FullConversationsUpdate();
|
||||||
|
int NewMessageNotification(CSMSConversation* Conversation, int MessageIndex);
|
||||||
|
int SendEditMessage();
|
||||||
|
|
||||||
|
int UpdateDisplayedConversation(int MessageIndex = -1);
|
||||||
|
virtual bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
|
||||||
|
CSMSDatabase *mSMSDatabase;
|
||||||
|
CSMSConversation *mSelectedConversation;
|
||||||
|
CSMSClient *mProgramHandle;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int mCharCounter, mMsgCounter;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
// void ConversationSelected(QTreeWidgetItem * item, int column);
|
||||||
|
void ConversationClicked(QTreeWidgetItem * item, int column);
|
||||||
|
void SendMsgBtnClicked(bool);
|
||||||
|
void SMSEditZoneContentsChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SMSGUI_H
|
||||||
291
Sources/SMSClient/SMSMasterCtrlInterface.cpp
Normal file
291
Sources/SMSClient/SMSMasterCtrlInterface.cpp
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
#include "SMSMasterCtrlInterface.h"
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QBuffer>
|
||||||
|
#include "SystemGui.h"
|
||||||
|
#include "Contact.h"
|
||||||
|
#include "SMSClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
CSMSMasterCtrlInterface::CSMSMasterCtrlInterface(CSMSClient *ProgramHandle)
|
||||||
|
{
|
||||||
|
mDeviceAddress = 1;
|
||||||
|
mNetworkPort = 2182;
|
||||||
|
mMasterCtrlAddress = "127.0.0.1";
|
||||||
|
// mNetworkPort = 6463;
|
||||||
|
// mMasterCtrlAddress = "192.168.0.112";
|
||||||
|
mNetworkCommSocket = 0;
|
||||||
|
mMyDeviceID = ID_SMS_CLIENT;
|
||||||
|
|
||||||
|
mProgramHandle = ProgramHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMSMasterCtrlInterface::~CSMSMasterCtrlInterface()
|
||||||
|
{
|
||||||
|
if(mNetworkCommSocket !=0)
|
||||||
|
{
|
||||||
|
// mNetworkCommSocket->disconnectFromHost();
|
||||||
|
// delete mNetworkCommSocket;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//int CSMSMasterCtrlInterface::ConnectToMasterCtrl()
|
||||||
|
//{
|
||||||
|
//// if(mNetworkCommSocket == 0)
|
||||||
|
//// {
|
||||||
|
//// mNetworkCommSocket = new QTcpSocket();
|
||||||
|
//// }
|
||||||
|
//// connect(mNetworkCommSocket,SIGNAL(connected()),this,SLOT(NetworkSocketConnected()));
|
||||||
|
//// connect(mNetworkCommSocket,SIGNAL(disconnected()),this,SLOT(NetworkSocketDisconnected()));
|
||||||
|
//// connect(mNetworkCommSocket,SIGNAL(readyRead()),this,SLOT(NetworkSocketDataAvailable()));
|
||||||
|
|
||||||
|
//// mNetworkCommSocket->connectToHost(mMasterCtrlAddress,mNetworkPort);
|
||||||
|
|
||||||
|
// return RET_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
int CSMSMasterCtrlInterface::DeviceConnectedToMaster(bool Connected)
|
||||||
|
{
|
||||||
|
if(Connected)
|
||||||
|
{
|
||||||
|
mNetworkCommSocket->write(GetTxPacket(SMS_CLIENT_DEVICE_DID_INFO_REQUEST,0,0,0,1,ID_MASTER,ID_SMS_CLIENT,mDeviceAddress));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//???
|
||||||
|
}
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSMasterCtrlInterface::DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderDeviceID, int SenderAddress, int MessageID, int DataSize, QByteArray Data)
|
||||||
|
{
|
||||||
|
Q_UNUSED(DataSize)
|
||||||
|
|
||||||
|
|
||||||
|
// if(TargetDeviceID == ID_ETHERNET_VIRTUAL)
|
||||||
|
// {
|
||||||
|
// switch(MessageID)
|
||||||
|
// {
|
||||||
|
// case ETH_NETWK_DEVICE_INFO_REQUEST:
|
||||||
|
// {
|
||||||
|
// QByteArray Frame,ResponseData;
|
||||||
|
// ResponseData.append((char)ID_SMS_CLIENT);
|
||||||
|
// ResponseData.append((char)mDeviceAddress);
|
||||||
|
// Frame = GetTxPacket(ETH_NETWK_DEVICE_INFO_RESPONSE,0,ResponseData.data(),ResponseData.size(),1,ID_MASTER,ID_ETHERNET_VIRTUAL,mDeviceAddress);
|
||||||
|
// mNetworkCommSocket->write(Frame);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// case ETH_NETWK_CONNECTION_REFUSED:
|
||||||
|
// {
|
||||||
|
// qDebug("MasterCtrl connection refused");
|
||||||
|
// mNetworkCommSocket->close();
|
||||||
|
// delete mNetworkCommSocket;
|
||||||
|
// mNetworkCommSocket = 0;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// case ETH_NETWK_SET_DEVICE_INFO_ACK:
|
||||||
|
// {
|
||||||
|
// mNetworkCommSocket->write(GetTxPacket(SMS_CLIENT_DEVICE_DID_INFO_REQUEST,0,0,0,1,ID_MASTER,ID_SMS_CLIENT,mDeviceAddress));
|
||||||
|
// qDebug("MasterCtrl accepted connection");
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// case ETH_NETWK_DEVICE_INFO_RESPONSE:
|
||||||
|
// default:
|
||||||
|
// {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
/* else*/ if(TargetDeviceID == ID_SMS_CLIENT && (TargetDeviceAddress == BROADCAST_VALUE || TargetDeviceAddress == mDeviceAddress))
|
||||||
|
{
|
||||||
|
switch(MessageID)
|
||||||
|
{
|
||||||
|
case SMS_CLIENT_DEVICE_ACK:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMS_CLIENT_DEVICE_STATUS_REQUEST:
|
||||||
|
{
|
||||||
|
QByteArray Frame,ResponseData;
|
||||||
|
ResponseData.append(ACK);
|
||||||
|
ResponseData.append((char)SMS_CLIENT_DEVICE_STATUS_REQUEST);
|
||||||
|
Frame = GetTxPacket(SMS_CLIENT_DEVICE_STATUS_RESPONSE,0,ResponseData.data(),ResponseData.size(),1,ID_MASTER,ID_SMS_CLIENT,mDeviceAddress);
|
||||||
|
mNetworkCommSocket->write(Frame);
|
||||||
|
// qDebug("Rx Status Request");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMS_CLIENT_DEVICE_DID_INFO_RESPONSE:
|
||||||
|
{
|
||||||
|
QString DidInfo;
|
||||||
|
QDataStream *Strm = new QDataStream(Data);
|
||||||
|
*Strm >> DidInfo;
|
||||||
|
delete Strm;
|
||||||
|
qDebug("Rx DID info: %s",DidInfo.toUtf8().data());
|
||||||
|
mProgramHandle->SetDIDDatabase(DidInfo);
|
||||||
|
|
||||||
|
// mNetworkCommSocket->write(GetTxPacket(SMS_CLIENT_DEVICE_GET_ALL_MSG_REQUEST,0,0,0,1,ID_MASTER,ID_SMS_CLIENT,mDeviceAddress));
|
||||||
|
mNetworkCommSocket->write(GetTxPacket(SMS_CLIENT_DEVICE_GET_CONTACTS_REQUEST,0,0,0,1,ID_MASTER,ID_SMS_CLIENT,mDeviceAddress));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMS_CLIENT_DEVICE_GET_ALL_MSG_RESPONSE:
|
||||||
|
{
|
||||||
|
QList<CSMSMessage> RAWSMSList;
|
||||||
|
QDataStream *Stream = new QDataStream(Data);
|
||||||
|
CSMSMessage NewMsg;
|
||||||
|
|
||||||
|
int NbMsg;
|
||||||
|
*Stream >> NbMsg;
|
||||||
|
|
||||||
|
for(int i = 0; i < NbMsg; i++)
|
||||||
|
{
|
||||||
|
*Stream >> NewMsg;
|
||||||
|
RAWSMSList.append(NewMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
mProgramHandle->SetAllMsgsDatabase("",&RAWSMSList);
|
||||||
|
|
||||||
|
RAWSMSList.clear();
|
||||||
|
|
||||||
|
|
||||||
|
delete Stream;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMS_CLIENT_DEVICE_NEW_MSG_NOTIFICATION:
|
||||||
|
{
|
||||||
|
QList<CSMSMessage> RAWSMSList;
|
||||||
|
QDataStream *Stream = new QDataStream(Data);
|
||||||
|
CSMSMessage NewMsg;
|
||||||
|
|
||||||
|
int NbMsg;
|
||||||
|
*Stream >> NbMsg;
|
||||||
|
|
||||||
|
for(int i = 0; i < NbMsg; i++)
|
||||||
|
{
|
||||||
|
*Stream >> NewMsg;
|
||||||
|
RAWSMSList.append(NewMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
mProgramHandle->NewMessagesEvent(&RAWSMSList);
|
||||||
|
|
||||||
|
RAWSMSList.clear();
|
||||||
|
|
||||||
|
|
||||||
|
delete Stream;
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMS_CLIENT_DEVICE_SEND_SMS_ACK:
|
||||||
|
{
|
||||||
|
|
||||||
|
QDataStream *Stream = new QDataStream(Data);
|
||||||
|
qint32 Success;
|
||||||
|
*Stream >> Success;
|
||||||
|
if(Success == 1)
|
||||||
|
{
|
||||||
|
qDebug("SMS Sent!!!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Send SMS Failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
delete Stream;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMS_CLIENT_DEVICE_GET_CONTACTS_RESPONSE:
|
||||||
|
{
|
||||||
|
QList<CContact> ContactsList;
|
||||||
|
QDataStream *Stream = new QDataStream(Data);
|
||||||
|
CContact NewContact;
|
||||||
|
|
||||||
|
int NbContact;
|
||||||
|
*Stream >> NbContact;
|
||||||
|
|
||||||
|
for(int i = 0; i < NbContact; i++)
|
||||||
|
{
|
||||||
|
*Stream >> NewContact;
|
||||||
|
ContactsList.append(NewContact);
|
||||||
|
}
|
||||||
|
|
||||||
|
mProgramHandle->SetContacts(&ContactsList);
|
||||||
|
|
||||||
|
ContactsList.clear();
|
||||||
|
qDebug("Contacts downloaded!");
|
||||||
|
|
||||||
|
|
||||||
|
delete Stream;
|
||||||
|
|
||||||
|
mNetworkCommSocket->write(GetTxPacket(SMS_CLIENT_DEVICE_GET_ALL_MSG_REQUEST,0,0,0,1,ID_MASTER,ID_SMS_CLIENT,mDeviceAddress));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMS_CLIENT_DEVICE_CONTACTS_CHANGED_NOTIFICATION:
|
||||||
|
{
|
||||||
|
mNetworkCommSocket->write(GetTxPacket(SMS_CLIENT_DEVICE_GET_CONTACTS_REQUEST,0,0,0,1,ID_MASTER,ID_SMS_CLIENT,mDeviceAddress));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SMS_CLIENT_DEVICE_SEND_SMS_REQUEST:
|
||||||
|
case SMS_CLIENT_DEVICE_STATUS_RESPONSE:
|
||||||
|
case SMS_CLIENT_DEVICE_DID_INFO_REQUEST:
|
||||||
|
case SMS_CLIENT_DEVICE_GET_ALL_MSG_REQUEST:
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
qDebug("SMSDevice: Invalid Ethernet MSg received: %d",MessageID);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//int CSMSMasterCtrlInterface::DisconnectMasterCtrl()
|
||||||
|
//{
|
||||||
|
// if(mNetworkCommSocket != 0)
|
||||||
|
// {
|
||||||
|
// mNetworkCommSocket->close();
|
||||||
|
// // mNetworkCommSocket->deleteLater();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return RET_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CSMSMasterCtrlInterface::NetworkSocketConnected()
|
||||||
|
//{
|
||||||
|
// qDebug("Connected to MasterCtrl");
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CSMSMasterCtrlInterface::NetworkSocketDataAvailable()
|
||||||
|
//{
|
||||||
|
// AnalyzeRxBuffer(mNetworkCommSocket->readAll());
|
||||||
|
//}
|
||||||
|
|
||||||
|
void CSMSMasterCtrlInterface::SendSMS(CSMSMessage Message)
|
||||||
|
{
|
||||||
|
QByteArray FrameData;
|
||||||
|
QBuffer FrameBuffer(&FrameData);
|
||||||
|
FrameBuffer.open(QIODevice::ReadWrite);
|
||||||
|
QDataStream *FrameDataStrm = new QDataStream(&FrameBuffer);
|
||||||
|
|
||||||
|
qint32 NbMsg = 1;
|
||||||
|
|
||||||
|
*FrameDataStrm << NbMsg << Message;
|
||||||
|
|
||||||
|
FrameBuffer.seek(0);
|
||||||
|
|
||||||
|
mNetworkCommSocket->write(GetTxPacket(SMS_CLIENT_DEVICE_SEND_SMS_REQUEST,0,FrameData,FrameData.size(),1,ID_MASTER));
|
||||||
|
|
||||||
|
FrameBuffer.close();
|
||||||
|
delete FrameDataStrm;
|
||||||
|
}
|
||||||
|
|
||||||
|
//void CSMSMasterCtrlInterface::NetworkSocketDisconnected()
|
||||||
|
//{
|
||||||
|
// qDebug("Disconnected from MasterCtrl");
|
||||||
|
//// delete mNetworkCommSocket;
|
||||||
|
//// mNetworkCommSocket = 0;
|
||||||
|
//}
|
||||||
47
Sources/SMSClient/SMSMasterCtrlInterface.h
Normal file
47
Sources/SMSClient/SMSMasterCtrlInterface.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#ifndef CSMSMASTERCTRLINTERFACE_H
|
||||||
|
#define CSMSMASTERCTRLINTERFACE_H
|
||||||
|
|
||||||
|
//#include "NetworkProtocol.h"
|
||||||
|
//#include "GlobalDefine.h"
|
||||||
|
//#include "ProtocolDefs.h"
|
||||||
|
//#include <QTcpSocket>
|
||||||
|
//#include "SMSMessage.h"
|
||||||
|
#include "MasterCtrlInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
class CSystemGui;
|
||||||
|
class CSMSClient
|
||||||
|
;
|
||||||
|
class CSMSMasterCtrlInterface: public CMasterCtrlInterface//CNetworkProtocol
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CSMSMasterCtrlInterface(CSMSClient *ProgramHandle);
|
||||||
|
~CSMSMasterCtrlInterface();
|
||||||
|
|
||||||
|
CSMSClient *mProgramHandle;
|
||||||
|
|
||||||
|
// virtual int DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data);
|
||||||
|
|
||||||
|
// QTcpSocket *mNetworkCommSocket;
|
||||||
|
// int mDeviceAddress;
|
||||||
|
// int mNetworkPort;
|
||||||
|
// QString mMasterCtrlAddress;
|
||||||
|
|
||||||
|
|
||||||
|
// int ConnectToMasterCtrl();
|
||||||
|
// int DisconnectMasterCtrl();
|
||||||
|
// virtual int NewFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data);
|
||||||
|
|
||||||
|
virtual int DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data);
|
||||||
|
virtual int DeviceConnectedToMaster(bool Connected);
|
||||||
|
|
||||||
|
void SendSMS(CSMSMessage Message);
|
||||||
|
|
||||||
|
//public slots:
|
||||||
|
// void NetworkSocketConnected();
|
||||||
|
// void NetworkSocketDataAvailable();
|
||||||
|
// void NetworkSocketDisconnected();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CSMSMasterCtrlInterface_H
|
||||||
63
Sources/SMSClient/SMSMessage.cpp
Normal file
63
Sources/SMSClient/SMSMessage.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include "SMSMessage.h"
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CSMSMessage::CSMSMessage()
|
||||||
|
{
|
||||||
|
this->mContact = "INVALID";
|
||||||
|
this->mDateTime = QDateTime::currentDateTime();
|
||||||
|
this->mDID = "INVALID";
|
||||||
|
this->mMessageText = "INVALID";
|
||||||
|
this->mType = SMS_INVALID_TYPE;
|
||||||
|
this->mVOIPMSDatabaseID = "INVALID";
|
||||||
|
|
||||||
|
mIsRead = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMSMessage::CSMSMessage(const CSMSMessage &Message)
|
||||||
|
{
|
||||||
|
this->mContact = Message.mContact;
|
||||||
|
this->mDateTime = Message.mDateTime;
|
||||||
|
this->mDID = Message.mDID;
|
||||||
|
this->mMessageText = Message.mMessageText;
|
||||||
|
this->mType = Message.mType;
|
||||||
|
this->mVOIPMSDatabaseID = Message.mVOIPMSDatabaseID;
|
||||||
|
|
||||||
|
mIsRead = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CSMSMessage::~CSMSMessage()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CSMSMessage &source)
|
||||||
|
{
|
||||||
|
|
||||||
|
out << source.mDID
|
||||||
|
<< source.mDateTime
|
||||||
|
<< source.mMessageText
|
||||||
|
<< source.mContact
|
||||||
|
<< (qint32)source.mType
|
||||||
|
<< source.mVOIPMSDatabaseID;
|
||||||
|
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CSMSMessage &dest)
|
||||||
|
{
|
||||||
|
qint32 temp;
|
||||||
|
in >> dest.mDID
|
||||||
|
>> dest.mDateTime
|
||||||
|
>> dest.mMessageText
|
||||||
|
>> dest.mContact
|
||||||
|
>> temp
|
||||||
|
>> dest.mVOIPMSDatabaseID;
|
||||||
|
|
||||||
|
dest.mType = (eSMSType)temp;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
44
Sources/SMSClient/SMSMessage.h
Normal file
44
Sources/SMSClient/SMSMessage.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#ifndef CSMSMESSAGE_H
|
||||||
|
#define CSMSMESSAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
typedef enum eSMSType
|
||||||
|
{
|
||||||
|
SMS_SENT_TYPE,
|
||||||
|
SMS_RECEIVED_TYPE,
|
||||||
|
SMS_INVALID_TYPE
|
||||||
|
}SmsType_t;
|
||||||
|
|
||||||
|
class CSMSMessage
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
CSMSMessage();
|
||||||
|
CSMSMessage(const CSMSMessage &Message);
|
||||||
|
~CSMSMessage();
|
||||||
|
|
||||||
|
/*qint64*/QString mVOIPMSDatabaseID;
|
||||||
|
QDateTime mDateTime;
|
||||||
|
SmsType_t mType;
|
||||||
|
QString mDID, mContact, mMessageText;
|
||||||
|
|
||||||
|
bool mIsRead;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// [id] => 111120
|
||||||
|
// [date] => 2014-03-30 10:24:16
|
||||||
|
// [type] => 0
|
||||||
|
// [did] => 8574884828
|
||||||
|
// [contact] => 8577884821
|
||||||
|
// [message] => hello+john
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CSMSMessage &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CSMSMessage &dest);
|
||||||
|
|
||||||
|
#endif // CSMSOBJECT_H
|
||||||
147
Sources/SettingsWindow.cpp
Normal file
147
Sources/SettingsWindow.cpp
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
#include "SettingsWindow.h"
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include "SMSClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
CSettingsWindow::CSettingsWindow()
|
||||||
|
{
|
||||||
|
resize(600,600);
|
||||||
|
|
||||||
|
QVBoxLayout *MainLayout = new QVBoxLayout;
|
||||||
|
QWidget *mPagesContainer = new QWidget(this);
|
||||||
|
|
||||||
|
mOptionsTabBar = new QTabBar();
|
||||||
|
mOptionsTabBar->addTab("SMS");
|
||||||
|
mOptionsTabBar->addTab("Network");
|
||||||
|
mOptionsTabBar->resize(this->geometry().width(),mOptionsTabBar->height());
|
||||||
|
MainLayout->addWidget(mOptionsTabBar);
|
||||||
|
|
||||||
|
mSMSPage = new QWidget(mPagesContainer);
|
||||||
|
// mVoipPage->resize(this->size());
|
||||||
|
|
||||||
|
QGridLayout *mSMSPageLayout = new QGridLayout;
|
||||||
|
|
||||||
|
|
||||||
|
QLabel *Label;
|
||||||
|
mVoipMSUsername = new QLineEdit;
|
||||||
|
Label = new QLabel("Voip.ms Username: ");
|
||||||
|
mSMSPageLayout->addWidget(Label,0,1,1,1);
|
||||||
|
mSMSPageLayout->addWidget(mVoipMSUsername,0,2,1,2/*,Qt::AlignLeft*/);
|
||||||
|
|
||||||
|
Label = new QLabel("Voip.ms Password: ");
|
||||||
|
mVoipMSPassword = new QLineEdit;
|
||||||
|
mVoipMSPassword->setEchoMode(QLineEdit::Password);
|
||||||
|
mSMSPageLayout->addWidget(Label,1,1,1,1);
|
||||||
|
mSMSPageLayout->addWidget(mVoipMSPassword,1,2,1,1/*,Qt::AlignLeft*/);
|
||||||
|
|
||||||
|
mRetreiveDIDSButton = new QPushButton("Get DIDs");
|
||||||
|
connect(mRetreiveDIDSButton,SIGNAL(clicked(bool)),this,SLOT(RetreiveDIDButtonClicked(bool)));
|
||||||
|
mSMSPageLayout->addWidget(mRetreiveDIDSButton,1,3,1,1);
|
||||||
|
|
||||||
|
|
||||||
|
Label = new QLabel("DID:");
|
||||||
|
mDIDSelectionDropList = new QComboBox();
|
||||||
|
mSMSPageLayout->addWidget(Label,2,1,1,1);
|
||||||
|
mSMSPageLayout->addWidget(mDIDSelectionDropList,2,2,1,1);
|
||||||
|
|
||||||
|
|
||||||
|
mVoipMSCalendar = new QCalendarWidget;
|
||||||
|
Label = new QLabel("SMS retreival stard date:");
|
||||||
|
mSMSPageLayout->addWidget(Label,3,1,1,1);
|
||||||
|
mSMSPageLayout->addWidget(mVoipMSCalendar,4,1,1,4);
|
||||||
|
|
||||||
|
mDoneButton = new QPushButton("Done");
|
||||||
|
MainLayout->addWidget(mDoneButton);
|
||||||
|
connect(mDoneButton,SIGNAL(clicked(bool)),this,SLOT(DoneButtonClicked(bool)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mSMSPage->setLayout(mSMSPageLayout);
|
||||||
|
mSMSPage->show();
|
||||||
|
|
||||||
|
MainLayout->addWidget(mPagesContainer);
|
||||||
|
setLayout(MainLayout);
|
||||||
|
|
||||||
|
connect(mOptionsTabBar,SIGNAL(currentChanged(int)),this,SLOT(TabBarClicked(int)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CSettingsWindow::~CSettingsWindow()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsWindow::TabBarClicked(int TabIndex)
|
||||||
|
{
|
||||||
|
if(TabIndex == 0)//SMS
|
||||||
|
{
|
||||||
|
mSMSPage->show();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(TabIndex == 1)//Network
|
||||||
|
{
|
||||||
|
mSMSPage->hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsWindow::RetreiveDIDButtonClicked(bool checked)
|
||||||
|
{
|
||||||
|
Q_UNUSED(checked)
|
||||||
|
|
||||||
|
if(mVoipMSUsername->text().isEmpty() || mVoipMSPassword->text().isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
qDebug("CLick!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsWindow::DIDsListFetched(QStringList DIDs)
|
||||||
|
{
|
||||||
|
if(DIDs.size() == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mDIDSelectionDropList->clear();
|
||||||
|
for(int i = 0; i < DIDs.size(); i++)
|
||||||
|
{
|
||||||
|
mDIDSelectionDropList->addItem(DIDs.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CSettingsWindow::SetSettingsData(CSettings *SettingsData)
|
||||||
|
{
|
||||||
|
mVoipMSPassword->setText(SettingsData->mVoipMSSettings.mPassword);
|
||||||
|
mVoipMSUsername->setText(SettingsData->mVoipMSSettings.mUsername);
|
||||||
|
mDIDSelectionDropList->clear();
|
||||||
|
mDIDSelectionDropList->addItem(SettingsData->mVoipMSSettings.mDefaultDID);
|
||||||
|
mVoipMSCalendar->setSelectedDate(SettingsData->mVoipMSSettings.mStartDate);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsWindow::DoneButtonClicked(bool checked)
|
||||||
|
{
|
||||||
|
Q_UNUSED(checked)
|
||||||
|
|
||||||
|
CSettings *Settings = new CSettings;
|
||||||
|
Settings->mVoipMSSettings.mDefaultDID = mDIDSelectionDropList->currentText();
|
||||||
|
Settings->mVoipMSSettings.mPassword = mVoipMSPassword->text();
|
||||||
|
Settings->mVoipMSSettings.mStartDate = mVoipMSCalendar->selectedDate();
|
||||||
|
Settings->mVoipMSSettings.mUsername = mVoipMSUsername->text();
|
||||||
|
|
||||||
|
mProgramHandle->SaveSettings(Settings);
|
||||||
|
mProgramHandle->SettingsWindowClosed();
|
||||||
|
delete Settings;
|
||||||
|
|
||||||
|
this->hide();
|
||||||
|
}
|
||||||
44
Sources/SettingsWindow.h
Normal file
44
Sources/SettingsWindow.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#ifndef CSETTINGSWINDOW_H
|
||||||
|
#define CSETTINGSWINDOW_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QTabBar>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QCalendarWidget>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include "ProgramSettings.h"
|
||||||
|
|
||||||
|
class CSMSClient;
|
||||||
|
|
||||||
|
|
||||||
|
class CSettingsWindow : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CSettingsWindow();
|
||||||
|
virtual ~CSettingsWindow();
|
||||||
|
|
||||||
|
CSMSClient *mProgramHandle;
|
||||||
|
|
||||||
|
QWidget *mSMSPage;
|
||||||
|
QTabBar *mOptionsTabBar;
|
||||||
|
QLineEdit *mVoipMSUsername;
|
||||||
|
QLineEdit *mVoipMSPassword;
|
||||||
|
QCalendarWidget *mVoipMSCalendar;
|
||||||
|
QComboBox *mDIDSelectionDropList;
|
||||||
|
QPushButton *mRetreiveDIDSButton;
|
||||||
|
|
||||||
|
QPushButton *mDoneButton;
|
||||||
|
|
||||||
|
unsigned int SetSettingsData(CSettings *SettingsData);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void TabBarClicked(int);
|
||||||
|
void RetreiveDIDButtonClicked(bool);
|
||||||
|
void DIDsListFetched(QStringList);
|
||||||
|
void DoneButtonClicked(bool);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CSETTINGSWINDOW_H
|
||||||
13
Sources/Sprinkler/SprinklerGui.cpp
Normal file
13
Sources/Sprinkler/SprinklerGui.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "SprinklerGui.h"
|
||||||
|
#include "ui_SprinklerGui.h"
|
||||||
|
|
||||||
|
CSprinklerGui::CSprinklerGui(QWidget *parent) :
|
||||||
|
QWidget(parent)
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSprinklerGui::~CSprinklerGui()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
23
Sources/Sprinkler/SprinklerGui.h
Normal file
23
Sources/Sprinkler/SprinklerGui.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef SPRINKLERGUI_H
|
||||||
|
#define SPRINKLERGUI_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "ui_SprinklerGui.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class CSprinklerGui;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CSprinklerGui : public QWidget, public Ui::CSprinklerGui
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CSprinklerGui(QWidget *parent = 0);
|
||||||
|
~CSprinklerGui();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SPRINKLERGUI_H
|
||||||
32
Sources/Sprinkler/SprinklerGui.ui
Normal file
32
Sources/Sprinkler/SprinklerGui.ui
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CSprinklerGui</class>
|
||||||
|
<widget class="QWidget" name="CSprinklerGui">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1047</width>
|
||||||
|
<height>560</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>-10</y>
|
||||||
|
<width>201</width>
|
||||||
|
<height>51</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Sprinklers</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
62
Sources/SystemGui.cpp
Normal file
62
Sources/SystemGui.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#include "SystemGui.h"
|
||||||
|
|
||||||
|
|
||||||
|
CSystemGui::CSystemGui(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
mGui = new CGuiMain();
|
||||||
|
mProgramSettings = new CProgramSettings();
|
||||||
|
mSMSClient = new CSMSClient(mGui->mSMSGui,&mSettings.mVoipMSSettings);
|
||||||
|
|
||||||
|
mSysTrayMgr = new CSystemTrayManager();
|
||||||
|
mSysTrayMgr->mProgramHandle=this;
|
||||||
|
mSMSClient->mTrayIconMgr = mSysTrayMgr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CSystemGui::~CSystemGui()
|
||||||
|
{
|
||||||
|
delete mGui;
|
||||||
|
delete mSMSClient;
|
||||||
|
delete mProgramSettings;
|
||||||
|
delete mSysTrayMgr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSystemGui::Start()
|
||||||
|
{
|
||||||
|
mProgramSettings->LoadSettings(&mSettings);
|
||||||
|
mGui->show();
|
||||||
|
mSMSClient->Start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSystemGui::ShowSettingsWindowRequest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSystemGui::QuitApplicationRequest()
|
||||||
|
{
|
||||||
|
QApplication::exit(69);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSystemGui::RespawnMainWindowRequest()
|
||||||
|
{
|
||||||
|
//qDebug("Respawn request");
|
||||||
|
mGui->RespawnMainWindow();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSystemGui::TrayIconLeftClick()
|
||||||
|
{
|
||||||
|
if(mGui->isVisible())
|
||||||
|
{
|
||||||
|
mGui->hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mGui->RespawnMainWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
37
Sources/SystemGui.h
Normal file
37
Sources/SystemGui.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#ifndef SYSTEMGUI_H
|
||||||
|
#define SYSTEMGUI_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "GuiMain.h"
|
||||||
|
#include "SMSClient.h"
|
||||||
|
#include "ProgramSettings.h"
|
||||||
|
#include "SystemTrayManager.h"
|
||||||
|
|
||||||
|
class CSystemGui : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CSystemGui(QObject *parent = 0);
|
||||||
|
~CSystemGui();
|
||||||
|
|
||||||
|
void Start();
|
||||||
|
|
||||||
|
void ShowSettingsWindowRequest();
|
||||||
|
void QuitApplicationRequest();
|
||||||
|
int RespawnMainWindowRequest();
|
||||||
|
int TrayIconLeftClick();
|
||||||
|
|
||||||
|
private:
|
||||||
|
CGuiMain *mGui;
|
||||||
|
CSMSClient *mSMSClient;
|
||||||
|
CProgramSettings *mProgramSettings;
|
||||||
|
CSettings mSettings;
|
||||||
|
CSystemTrayManager *mSysTrayMgr;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SYSTEMGUI_H
|
||||||
96
Sources/SystemTrayManager.cpp
Normal file
96
Sources/SystemTrayManager.cpp
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#include "SystemTrayManager.h"
|
||||||
|
#include "SystemGui.h"
|
||||||
|
#include <QCursor>
|
||||||
|
|
||||||
|
CSystemTrayManager::CSystemTrayManager()
|
||||||
|
{
|
||||||
|
|
||||||
|
mProgramHandle = 0;
|
||||||
|
|
||||||
|
mTrayMenu = new QMenu();
|
||||||
|
|
||||||
|
connect(&mSystemTrayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(TrayIconActivated(QSystemTrayIcon::ActivationReason)));
|
||||||
|
connect(&mSystemTrayIcon,SIGNAL(messageClicked()),this,SLOT(TrayBaloonMessageClicked()));
|
||||||
|
connect(mTrayMenu,SIGNAL(triggered(QAction*)),this,SLOT(TrayMenuClicked(QAction*)));
|
||||||
|
|
||||||
|
mShowSettingsGUIAction = mTrayMenu->addAction("Settings");
|
||||||
|
mQuitAction = mTrayMenu->addAction("Quit SMS Client");
|
||||||
|
mSystemTrayIcon.setIcon(QIcon("./Ico/sms.png"));
|
||||||
|
mSystemTrayIcon.setToolTip("SMS Client :)");
|
||||||
|
mSystemTrayIcon.show();
|
||||||
|
mSystemTrayIcon.setContextMenu(mTrayMenu);
|
||||||
|
|
||||||
|
}
|
||||||
|
CSystemTrayManager::~CSystemTrayManager()
|
||||||
|
{
|
||||||
|
mSystemTrayIcon.hide();
|
||||||
|
delete mTrayMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSystemTrayManager::TrayBaloonMessageClicked()
|
||||||
|
{
|
||||||
|
qDebug("Baloon message clicked");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSystemTrayManager::TrayIconActivated(QSystemTrayIcon::ActivationReason Reason)
|
||||||
|
{
|
||||||
|
// qDebug("Tray icon activated %d",Reason);
|
||||||
|
// mSystemTrayIcon.showMessage("Icon Clicked","The icon has\nbeen clicked.");
|
||||||
|
switch(Reason)
|
||||||
|
{
|
||||||
|
case QSystemTrayIcon::Unknown:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QSystemTrayIcon::Context:
|
||||||
|
{
|
||||||
|
//qDebug("Context");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QSystemTrayIcon::DoubleClick:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QSystemTrayIcon::Trigger:
|
||||||
|
{
|
||||||
|
//qDebug("Trigger");
|
||||||
|
//mTrayMenu->popup(QCursor::pos());
|
||||||
|
//mProgramHandle->RespawnMainWindowRequest();
|
||||||
|
mProgramHandle->TrayIconLeftClick();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QSystemTrayIcon::MiddleClick:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSystemTrayManager::TrayMenuClicked(QAction *Menu)
|
||||||
|
{
|
||||||
|
if(Menu == mQuitAction)
|
||||||
|
{
|
||||||
|
qDebug("Quit");
|
||||||
|
mProgramHandle->QuitApplicationRequest();
|
||||||
|
}
|
||||||
|
else if(Menu == mShowSettingsGUIAction)
|
||||||
|
{
|
||||||
|
qDebug("Settings");
|
||||||
|
mProgramHandle->ShowSettingsWindowRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSystemTrayManager::NewSMSMessagesPendingCount(int count)
|
||||||
|
{
|
||||||
|
if(count == 0)
|
||||||
|
{
|
||||||
|
mSystemTrayIcon.setIcon(QIcon("./Ico/sms.png"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mSystemTrayIcon.setIcon(QIcon("./Ico/sms_new.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
32
Sources/SystemTrayManager.h
Normal file
32
Sources/SystemTrayManager.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef CSYSTEMTRAYMANAGER_H
|
||||||
|
#define CSYSTEMTRAYMANAGER_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
class CSystemGui;
|
||||||
|
|
||||||
|
class CSystemTrayManager: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CSystemTrayManager();
|
||||||
|
virtual ~CSystemTrayManager();
|
||||||
|
CSystemGui *mProgramHandle;
|
||||||
|
int NewSMSMessagesPendingCount(int count);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSystemTrayIcon mSystemTrayIcon;
|
||||||
|
QMenu *mTrayMenu;
|
||||||
|
QAction *mQuitAction, *mShowSettingsGUIAction;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void TrayIconActivated(QSystemTrayIcon::ActivationReason);
|
||||||
|
void TrayBaloonMessageClicked();
|
||||||
|
void TrayMenuClicked(QAction*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CSYSTEMTRAYMANAGER_H
|
||||||
15
Sources/main.cpp
Normal file
15
Sources/main.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//#include "GuiMain.h"
|
||||||
|
#include "SystemGui.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
|
CSystemGui Program;
|
||||||
|
Program.Start();
|
||||||
|
// CGuiMain w;
|
||||||
|
// w.show();
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
67
SystemGui.pro
Normal file
67
SystemGui.pro
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2017-03-20T13:09:51
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += core gui network
|
||||||
|
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
TARGET = SystemGui
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
# The following define makes your compiler emit warnings if you use
|
||||||
|
# any feature of Qt which as been marked as deprecated (the exact warnings
|
||||||
|
# depend on your compiler). Please consult the documentation of the
|
||||||
|
# deprecated API in order to know how to port your code away from it.
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
|
# You can also make your code fail to compile if you use deprecated APIs.
|
||||||
|
# In order to do so, uncomment the following line.
|
||||||
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
|
INCLUDEPATH += Sources\
|
||||||
|
Sources/SMSClient\
|
||||||
|
Sources/Sprinkler\
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
Sources/GuiMain.cpp \
|
||||||
|
Sources/main.cpp \
|
||||||
|
Sources/NetworkProtocol.cpp \
|
||||||
|
Sources/ProgramSettings.cpp \
|
||||||
|
Sources/SystemGui.cpp \
|
||||||
|
Sources/SMSClient/SMSConversation.cpp \
|
||||||
|
Sources/SMSClient/SMSDatabase.cpp \
|
||||||
|
Sources/SMSClient/SMSGui.cpp \
|
||||||
|
Sources/SMSClient/SMSMessage.cpp \
|
||||||
|
Sources/SMSClient/SMSClient.cpp \
|
||||||
|
Sources/SMSClient/SMSMasterCtrlInterface.cpp \
|
||||||
|
Sources/MasterCtrlInterface.cpp \
|
||||||
|
Sources/SMSClient/Contact.cpp \
|
||||||
|
Sources/SMSClient/ContactRepository.cpp \
|
||||||
|
Sources/SystemTrayManager.cpp \
|
||||||
|
Sources/Sprinkler/SprinklerGui.cpp
|
||||||
|
|
||||||
|
HEADERS += Sources/AbstractNetworkInterface.h \
|
||||||
|
Sources/GuiMain.h \
|
||||||
|
Sources/NetworkProtocol.h \
|
||||||
|
Sources/ProgramSettings.h \
|
||||||
|
Sources/ProtocolDefs.h \
|
||||||
|
Sources/SystemGui.h \
|
||||||
|
Sources/SMSClient/SMSConversation.h \
|
||||||
|
Sources/SMSClient/SMSDatabase.h \
|
||||||
|
Sources/SMSClient/SMSGui.h \
|
||||||
|
Sources/SMSClient/SMSMessage.h \
|
||||||
|
Sources/SMSClient/SMSClient.h \
|
||||||
|
Sources/SMSClient/SMSMasterCtrlInterface.h \
|
||||||
|
Sources/MasterCtrlInterface.h \
|
||||||
|
Sources/SMSClient/Contact.h \
|
||||||
|
Sources/SMSClient/ContactRepository.h \
|
||||||
|
Sources/SystemTrayManager.h \
|
||||||
|
Sources/Sprinkler/SprinklerGui.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
SMSGui.ui \
|
||||||
|
Sources/Sprinkler/SprinklerGui.ui
|
||||||
120
ui_SMSGui.h
Normal file
120
ui_SMSGui.h
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
** Form generated from reading UI file 'SMSGui.ui'
|
||||||
|
**
|
||||||
|
** Created by: Qt User Interface Compiler version 5.5.0
|
||||||
|
**
|
||||||
|
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#ifndef UI_SMSGUI_H
|
||||||
|
#define UI_SMSGUI_H
|
||||||
|
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtWidgets/QAction>
|
||||||
|
#include <QtWidgets/QApplication>
|
||||||
|
#include <QtWidgets/QButtonGroup>
|
||||||
|
#include <QtWidgets/QFrame>
|
||||||
|
#include <QtWidgets/QGridLayout>
|
||||||
|
#include <QtWidgets/QHeaderView>
|
||||||
|
#include <QtWidgets/QLabel>
|
||||||
|
#include <QtWidgets/QPushButton>
|
||||||
|
#include <QtWidgets/QSpacerItem>
|
||||||
|
#include <QtWidgets/QTextBrowser>
|
||||||
|
#include <QtWidgets/QTextEdit>
|
||||||
|
#include <QtWidgets/QTreeWidget>
|
||||||
|
#include <QtWidgets/QWidget>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class Ui_CSMSGui
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QTextBrowser *mConversationText;
|
||||||
|
QFrame *mSMSEditFrame;
|
||||||
|
QGridLayout *gridLayout;
|
||||||
|
QPushButton *mSMSSendBtn;
|
||||||
|
QTextEdit *mSMSEdit;
|
||||||
|
QSpacerItem *horizontalSpacer;
|
||||||
|
QLabel *mSMSMessageStatsLabel;
|
||||||
|
QTreeWidget *mContactsTreeWidget;
|
||||||
|
QLabel *mContactPic;
|
||||||
|
QLabel *mContactName;
|
||||||
|
|
||||||
|
void setupUi(QWidget *CSMSGui)
|
||||||
|
{
|
||||||
|
if (CSMSGui->objectName().isEmpty())
|
||||||
|
CSMSGui->setObjectName(QStringLiteral("CSMSGui"));
|
||||||
|
CSMSGui->resize(803, 785);
|
||||||
|
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
sizePolicy.setHorizontalStretch(0);
|
||||||
|
sizePolicy.setVerticalStretch(0);
|
||||||
|
sizePolicy.setHeightForWidth(CSMSGui->sizePolicy().hasHeightForWidth());
|
||||||
|
CSMSGui->setSizePolicy(sizePolicy);
|
||||||
|
mConversationText = new QTextBrowser(CSMSGui);
|
||||||
|
mConversationText->setObjectName(QStringLiteral("mConversationText"));
|
||||||
|
mConversationText->setGeometry(QRect(0, 160, 481, 451));
|
||||||
|
mSMSEditFrame = new QFrame(CSMSGui);
|
||||||
|
mSMSEditFrame->setObjectName(QStringLiteral("mSMSEditFrame"));
|
||||||
|
mSMSEditFrame->setGeometry(QRect(0, 620, 521, 121));
|
||||||
|
mSMSEditFrame->setFrameShape(QFrame::StyledPanel);
|
||||||
|
mSMSEditFrame->setFrameShadow(QFrame::Raised);
|
||||||
|
gridLayout = new QGridLayout(mSMSEditFrame);
|
||||||
|
gridLayout->setObjectName(QStringLiteral("gridLayout"));
|
||||||
|
mSMSSendBtn = new QPushButton(mSMSEditFrame);
|
||||||
|
mSMSSendBtn->setObjectName(QStringLiteral("mSMSSendBtn"));
|
||||||
|
|
||||||
|
gridLayout->addWidget(mSMSSendBtn, 3, 2, 1, 1);
|
||||||
|
|
||||||
|
mSMSEdit = new QTextEdit(mSMSEditFrame);
|
||||||
|
mSMSEdit->setObjectName(QStringLiteral("mSMSEdit"));
|
||||||
|
|
||||||
|
gridLayout->addWidget(mSMSEdit, 2, 0, 2, 1);
|
||||||
|
|
||||||
|
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||||
|
|
||||||
|
gridLayout->addItem(horizontalSpacer, 3, 3, 1, 1);
|
||||||
|
|
||||||
|
mSMSMessageStatsLabel = new QLabel(mSMSEditFrame);
|
||||||
|
mSMSMessageStatsLabel->setObjectName(QStringLiteral("mSMSMessageStatsLabel"));
|
||||||
|
mSMSMessageStatsLabel->setMinimumSize(QSize(200, 75));
|
||||||
|
|
||||||
|
gridLayout->addWidget(mSMSMessageStatsLabel, 2, 2, 1, 2);
|
||||||
|
|
||||||
|
mContactsTreeWidget = new QTreeWidget(CSMSGui);
|
||||||
|
QTreeWidgetItem *__qtreewidgetitem = new QTreeWidgetItem();
|
||||||
|
__qtreewidgetitem->setText(0, QStringLiteral("1"));
|
||||||
|
mContactsTreeWidget->setHeaderItem(__qtreewidgetitem);
|
||||||
|
mContactsTreeWidget->setObjectName(QStringLiteral("mContactsTreeWidget"));
|
||||||
|
mContactsTreeWidget->setGeometry(QRect(520, 160, 256, 471));
|
||||||
|
mContactsTreeWidget->setIndentation(2);
|
||||||
|
mContactsTreeWidget->header()->setVisible(false);
|
||||||
|
mContactPic = new QLabel(CSMSGui);
|
||||||
|
mContactPic->setObjectName(QStringLiteral("mContactPic"));
|
||||||
|
mContactPic->setGeometry(QRect(10, 10, 141, 121));
|
||||||
|
mContactName = new QLabel(CSMSGui);
|
||||||
|
mContactName->setObjectName(QStringLiteral("mContactName"));
|
||||||
|
mContactName->setGeometry(QRect(180, 20, 591, 101));
|
||||||
|
|
||||||
|
retranslateUi(CSMSGui);
|
||||||
|
|
||||||
|
QMetaObject::connectSlotsByName(CSMSGui);
|
||||||
|
} // setupUi
|
||||||
|
|
||||||
|
void retranslateUi(QWidget *CSMSGui)
|
||||||
|
{
|
||||||
|
CSMSGui->setWindowTitle(QApplication::translate("CSMSGui", "Form", 0));
|
||||||
|
mSMSSendBtn->setText(QApplication::translate("CSMSGui", "Send", 0));
|
||||||
|
mSMSMessageStatsLabel->setText(QApplication::translate("CSMSGui", "TextLabel", 0));
|
||||||
|
mContactPic->setText(QApplication::translate("CSMSGui", "TextLabel", 0));
|
||||||
|
mContactName->setText(QApplication::translate("CSMSGui", "TextLabel", 0));
|
||||||
|
} // retranslateUi
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class CSMSGui: public Ui_CSMSGui {};
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // UI_SMSGUI_H
|
||||||
55
ui_SprinklerGui.h
Normal file
55
ui_SprinklerGui.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
** Form generated from reading UI file 'SprinklerGui.ui'
|
||||||
|
**
|
||||||
|
** Created by: Qt User Interface Compiler version 5.5.0
|
||||||
|
**
|
||||||
|
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#ifndef UI_SPRINKLERGUI_H
|
||||||
|
#define UI_SPRINKLERGUI_H
|
||||||
|
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtWidgets/QAction>
|
||||||
|
#include <QtWidgets/QApplication>
|
||||||
|
#include <QtWidgets/QButtonGroup>
|
||||||
|
#include <QtWidgets/QHeaderView>
|
||||||
|
#include <QtWidgets/QLabel>
|
||||||
|
#include <QtWidgets/QWidget>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class Ui_CSprinklerGui
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QLabel *label;
|
||||||
|
|
||||||
|
void setupUi(QWidget *CSprinklerGui)
|
||||||
|
{
|
||||||
|
if (CSprinklerGui->objectName().isEmpty())
|
||||||
|
CSprinklerGui->setObjectName(QStringLiteral("CSprinklerGui"));
|
||||||
|
CSprinklerGui->resize(1047, 560);
|
||||||
|
label = new QLabel(CSprinklerGui);
|
||||||
|
label->setObjectName(QStringLiteral("label"));
|
||||||
|
label->setGeometry(QRect(0, -10, 201, 51));
|
||||||
|
|
||||||
|
retranslateUi(CSprinklerGui);
|
||||||
|
|
||||||
|
QMetaObject::connectSlotsByName(CSprinklerGui);
|
||||||
|
} // setupUi
|
||||||
|
|
||||||
|
void retranslateUi(QWidget *CSprinklerGui)
|
||||||
|
{
|
||||||
|
CSprinklerGui->setWindowTitle(QApplication::translate("CSprinklerGui", "Form", 0));
|
||||||
|
label->setText(QApplication::translate("CSprinklerGui", "Sprinklers", 0));
|
||||||
|
} // retranslateUi
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class CSprinklerGui: public Ui_CSprinklerGui {};
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // UI_SPRINKLERGUI_H
|
||||||
Loading…
x
Reference in New Issue
Block a user