Dev...
This commit is contained in:
parent
8f5a0f68ff
commit
2139293944
BIN
Configuration/Contacts.mcc
Normal file
BIN
Configuration/Contacts.mcc
Normal file
Binary file not shown.
BIN
Ico/contact.png
Normal file
BIN
Ico/contact.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@ -21,7 +21,10 @@ HEADERS += \
|
||||
Sources/SMSDevice.h \
|
||||
Sources/NetworkDevice.h \
|
||||
Sources/AbstractNetworkInterface.h \
|
||||
Sources/VoipSMS/SMSMessage.h
|
||||
Sources/VoipSMS/SMSMessage.h \
|
||||
Sources/Gui/CContactsWindow.h \
|
||||
Sources/Contact.h \
|
||||
Sources/ContactRepository.h
|
||||
|
||||
SOURCES += \
|
||||
Sources/main.cpp \
|
||||
@ -41,7 +44,10 @@ SOURCES += \
|
||||
Sources/NetworkDevicesMgr.cpp \
|
||||
Sources/SMSDevice.cpp \
|
||||
Sources/NetworkDevice.cpp \
|
||||
Sources/VoipSMS/SMSMessage.cpp
|
||||
Sources/VoipSMS/SMSMessage.cpp \
|
||||
Sources/Gui/CContactsWindow.cpp \
|
||||
Sources/Contact.cpp \
|
||||
Sources/ContactRepository.cpp
|
||||
|
||||
|
||||
#win32:SOURCES += $$PWD/Source/qextserialport/win_qextserialport.cpp \
|
||||
|
||||
107
Sources/Contact.cpp
Normal file
107
Sources/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/Contact.h
Normal file
29
Sources/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
|
||||
161
Sources/ContactRepository.cpp
Normal file
161
Sources/ContactRepository.cpp
Normal file
@ -0,0 +1,161 @@
|
||||
#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::ChangeContact(int index, CContact Contact)
|
||||
{
|
||||
if(index < 0 || index >= mContactsList.size())
|
||||
{
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
mContactsList[index] = Contact;
|
||||
SaveContacts();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
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/ContactRepository.h
Normal file
27
Sources/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 AddContact(CContact Contact);
|
||||
int ChangeContact(int index, CContact Contact);
|
||||
QList<CContact> *GetContacts(){return &mContactsList;}
|
||||
int GetContact(int index, CContact &Contact);
|
||||
CContact *GetContactPtr(int index);
|
||||
int DeleteContact(int index);
|
||||
int GetContactCount(){return mContactsList.size();}
|
||||
|
||||
private:
|
||||
QList<CContact> mContactsList;
|
||||
};
|
||||
|
||||
#endif // CCONTACTREPOSITORY_H
|
||||
7
Sources/Gui/CContactsWindow.cpp
Normal file
7
Sources/Gui/CContactsWindow.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "CContactsWindow.h"
|
||||
|
||||
CContactsWindow::CContactsWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
11
Sources/Gui/CContactsWindow.h
Normal file
11
Sources/Gui/CContactsWindow.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef CCONTACTSWINDOW_H
|
||||
#define CCONTACTSWINDOW_H
|
||||
|
||||
|
||||
class CContactsWindow
|
||||
{
|
||||
public:
|
||||
CContactsWindow();
|
||||
};
|
||||
|
||||
#endif // CCONTACTSWINDOW_H
|
||||
@ -3,6 +3,8 @@
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include "MasterCtrl.h"
|
||||
#include <QFileDialog>
|
||||
|
||||
|
||||
|
||||
CSettingsWindow::CSettingsWindow()
|
||||
@ -15,9 +17,13 @@ CSettingsWindow::CSettingsWindow()
|
||||
mOptionsTabBar = new QTabBar();
|
||||
mOptionsTabBar->addTab("SMS");
|
||||
mOptionsTabBar->addTab("Network");
|
||||
mOptionsTabBar->addTab("Contacts");
|
||||
mOptionsTabBar->resize(this->geometry().width(),mOptionsTabBar->height());
|
||||
MainLayout->addWidget(mOptionsTabBar);
|
||||
|
||||
|
||||
//////////////////VOIP.MS config page/////////////////////
|
||||
|
||||
mSMSPage = new QWidget(mPagesContainer);
|
||||
// mVoipPage->resize(this->size());
|
||||
|
||||
@ -62,6 +68,73 @@ CSettingsWindow::CSettingsWindow()
|
||||
mSMSPage->setLayout(mSMSPageLayout);
|
||||
mSMSPage->show();
|
||||
|
||||
|
||||
|
||||
//////////////////VOIP.MS config page/////////////////////
|
||||
|
||||
mContactsPage = new QWidget(mPagesContainer);
|
||||
mContactsPage->resize(400,400);
|
||||
|
||||
mDefaultContactPixmap = new QPixmap(QPixmap("./Ico/contact.png").scaled(75,75));
|
||||
|
||||
QGridLayout *mContactsPageLayout = new QGridLayout;
|
||||
|
||||
mContactsList = new QTableWidget(0,2);
|
||||
mContactsList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
mContactsList->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
mContactsList->clearContents();
|
||||
mContactsList->setRowCount(0);
|
||||
mContactsList->setHorizontalHeaderLabels(QStringList() << "Contact" << "Name");
|
||||
mContactsPageLayout->addWidget(mContactsList,0,0,1,3);
|
||||
connect(mContactsList,SIGNAL(cellDoubleClicked(int,int)),SLOT(TableDoubleClicked(int,int)));
|
||||
//connect(mLogsTable,SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)),this,SLOT(TableCurItemChanged(QTableWidgetItem*,QTableWidgetItem*)));
|
||||
connect(mContactsList,SIGNAL(itemSelectionChanged()),this,SLOT(TableCellSelected(/*int,int*/)));
|
||||
|
||||
|
||||
|
||||
Label = new QLabel("Contact Name: ");
|
||||
mContactsPageLayout->addWidget(Label,1,1,1,1);
|
||||
mContactNameEdit = new QLineEdit();
|
||||
mContactsPageLayout->addWidget(mContactNameEdit,1,2,1,1);
|
||||
|
||||
Label = new QLabel("Contact Raw Number: ");
|
||||
mContactsPageLayout->addWidget(Label,2,1,1,1);
|
||||
mContactRawNbrEdit = new QLineEdit();
|
||||
// mContactRawNbrEdit->setInputMask("9");
|
||||
mContactsPageLayout->addWidget(mContactRawNbrEdit,2,2,1,1);
|
||||
|
||||
Label = new QLabel("Contact Number: ");
|
||||
mContactsPageLayout->addWidget(Label,3,1,1,1);
|
||||
mContactNbrEdit = new QLineEdit();
|
||||
mContactNbrEdit->setDisabled(true);
|
||||
mContactsPageLayout->addWidget(mContactNbrEdit,3,2,1,1);
|
||||
|
||||
mContactPixmapLabel = new QLabel();
|
||||
mContactPixmapLabel->setPixmap(*mDefaultContactPixmap);
|
||||
mContactsPageLayout->addWidget(mContactPixmapLabel,1,0,2,1);
|
||||
|
||||
|
||||
mSelectContactPicBtn = new QPushButton("Choose");
|
||||
mContactsPageLayout->addWidget(mSelectContactPicBtn,3,0,1,1);
|
||||
connect(mSelectContactPicBtn,SIGNAL(clicked(bool)),this,SLOT(SelectContactPicClicked(bool)));
|
||||
|
||||
|
||||
mNewContactBtn = new QPushButton("New");
|
||||
mContactsPageLayout->addWidget(mNewContactBtn,4,1,1,1);
|
||||
connect(mNewContactBtn,SIGNAL(clicked(bool)),this,SLOT(NewContactClicked(bool)));
|
||||
|
||||
mSaveContactBtn = new QPushButton("Save");
|
||||
mContactsPageLayout->addWidget(mSaveContactBtn,4,2,1,1);
|
||||
connect(mSaveContactBtn,SIGNAL(clicked(bool)),this,SLOT(SaveContactClicked(bool)));
|
||||
|
||||
mDeleteContactBtn = new QPushButton("Delete Contact");
|
||||
mContactsPageLayout->addWidget(mDeleteContactBtn,4,0,1,1);
|
||||
connect(mDeleteContactBtn,SIGNAL(clicked(bool)),this,SLOT(DeleteContactClicked(bool)));
|
||||
|
||||
mContactsPage->setLayout(mContactsPageLayout);
|
||||
mContactsPage->hide();
|
||||
|
||||
|
||||
MainLayout->addWidget(mPagesContainer);
|
||||
setLayout(MainLayout);
|
||||
|
||||
@ -79,12 +152,20 @@ void CSettingsWindow::TabBarClicked(int TabIndex)
|
||||
if(TabIndex == 0)//SMS
|
||||
{
|
||||
mSMSPage->show();
|
||||
mContactsPage->hide();
|
||||
|
||||
|
||||
}
|
||||
else if(TabIndex == 1)//Network
|
||||
{
|
||||
mSMSPage->hide();
|
||||
mContactsPage->hide();
|
||||
|
||||
}
|
||||
else if(TabIndex == 2)//Contacts
|
||||
{
|
||||
mSMSPage->hide();
|
||||
mContactsPage->show();
|
||||
|
||||
}
|
||||
}
|
||||
@ -145,3 +226,150 @@ void CSettingsWindow::DoneButtonClicked(bool checked)
|
||||
|
||||
this->hide();
|
||||
}
|
||||
|
||||
void CSettingsWindow::SelectContactPicClicked(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked)
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(this,tr("Select Image"), "", tr("Image Files (*.png *.jpg *.bmp)"));
|
||||
if(fileName.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// int Index =GetCurSelectedItemIndexInTable();
|
||||
|
||||
// if(Index >= 0)
|
||||
// {
|
||||
// mProgramHandle->GetContactRepository()->GetContactPtr(Index)->SetContactImage(fileName);
|
||||
// }
|
||||
|
||||
// mContactPixmap = mProgramHandle->GetContactRepository()->GetContactPtr(Index)->mContactPicture;
|
||||
|
||||
mContactPixmap = QPixmap(fileName);
|
||||
mContactPixmapLabel->setPixmap(mContactPixmap.scaled(75,75));
|
||||
|
||||
}
|
||||
|
||||
void CSettingsWindow::SaveContactClicked(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked)
|
||||
CContact NewContact(mContactRawNbrEdit->text(),mContactNameEdit->text(),&mContactPixmap);
|
||||
int index = GetCurSelectedItemIndexInTable();
|
||||
|
||||
mProgramHandle->GetContactRepository()->ChangeContact(index,NewContact);
|
||||
|
||||
UpdateContacts();
|
||||
|
||||
// delete NewContact;
|
||||
|
||||
}
|
||||
|
||||
void CSettingsWindow::DeleteContactClicked(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked)
|
||||
int Index =GetCurSelectedItemIndexInTable();
|
||||
|
||||
if(Index >= 0)
|
||||
{
|
||||
mProgramHandle->GetContactRepository()->DeleteContact(Index);
|
||||
}
|
||||
|
||||
UpdateContacts();
|
||||
mContactsList->setCurrentCell(0,0);
|
||||
}
|
||||
|
||||
void CSettingsWindow::NewContactClicked(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked)
|
||||
CContact NewContact("---");
|
||||
mProgramHandle->GetContactRepository()->AddContact(NewContact);
|
||||
|
||||
UpdateContacts();
|
||||
mContactsList->setCurrentCell(mContactsList->rowCount()-1,0);
|
||||
|
||||
}
|
||||
|
||||
int CSettingsWindow::UpdateContacts()
|
||||
{
|
||||
QList<CContact> *ContactsList;
|
||||
ClearTable();
|
||||
ContactsList = mProgramHandle->GetContactRepository()->GetContacts();
|
||||
|
||||
mContactsList->setRowCount(ContactsList->size());
|
||||
|
||||
for(int i = 0; i < ContactsList->size(); i++)
|
||||
{
|
||||
QTableWidgetItem * NewItem = new QTableWidgetItem(ContactsList->at(i).mContactNumber);
|
||||
NewItem->setData(Qt::UserRole,QVariant(i));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mContactsList->setItem(i,0,NewItem);
|
||||
|
||||
NewItem = new QTableWidgetItem(ContactsList->at(i).mContactName);
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mContactsList->setItem(i,1,NewItem);
|
||||
}
|
||||
|
||||
|
||||
mContactsList->resizeColumnsToContents();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CSettingsWindow::ClearTable()
|
||||
{
|
||||
for(int Col = 0; Col < mContactsList->columnCount(); Col++)
|
||||
{
|
||||
for(int Row = 0; Row < mContactsList->rowCount(); Row++)
|
||||
{
|
||||
delete mContactsList->item(Row,Col);
|
||||
//mLogsTable->item(Row,Col) = 0;
|
||||
}
|
||||
}
|
||||
mContactsList->setRowCount(0);
|
||||
mContactsList->clearContents();
|
||||
}
|
||||
|
||||
void CSettingsWindow::TableCellSelected(/*int row, int col*/)
|
||||
{
|
||||
int Selection = GetCurSelectedItemIndexInTable();
|
||||
|
||||
if(Selection == -1)
|
||||
return;
|
||||
|
||||
CContact SelectedContact;
|
||||
mProgramHandle->GetContactRepository()->GetContact(Selection,SelectedContact);
|
||||
|
||||
mContactRawNbrEdit->setText(SelectedContact.mRAWContactNbr);
|
||||
mContactNameEdit->setText(SelectedContact.mContactName);
|
||||
mContactNbrEdit->setText(SelectedContact.mContactNumber);
|
||||
|
||||
mContactPixmap = SelectedContact.mContactPicture;
|
||||
mContactPixmapLabel->setPixmap(mContactPixmap.scaled(75,75));
|
||||
|
||||
}
|
||||
|
||||
int CSettingsWindow::GetCurSelectedItemIndexInTable()
|
||||
{
|
||||
QList<QTableWidgetItem*> list = mContactsList->selectedItems();
|
||||
|
||||
if(list.size() == 0)
|
||||
return - 1;
|
||||
|
||||
int Selection = -1;
|
||||
for(int i = 0; i < list.size(); i++)
|
||||
{
|
||||
if(list.at(i)->column() == 0)
|
||||
{
|
||||
Selection = list.at(i)->data(Qt::UserRole).toInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Selection;
|
||||
}
|
||||
|
||||
void CSettingsWindow::TableDoubleClicked(int row, int col)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,9 @@
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include "ProgramSettings.h"
|
||||
#include "QTableWidget"
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
class CMasterCtrl;
|
||||
|
||||
@ -23,22 +26,49 @@ public:
|
||||
CMasterCtrl *mProgramHandle;
|
||||
|
||||
QWidget *mSMSPage;
|
||||
QWidget *mContactsPage;
|
||||
QTabBar *mOptionsTabBar;
|
||||
|
||||
//SMS Page
|
||||
QLineEdit *mVoipMSUsername;
|
||||
QLineEdit *mVoipMSPassword;
|
||||
QCalendarWidget *mVoipMSCalendar;
|
||||
QComboBox *mDIDSelectionDropList;
|
||||
QPushButton *mRetreiveDIDSButton;
|
||||
|
||||
//Contacts Page
|
||||
QTableWidget *mContactsList;
|
||||
QPixmap *mDefaultContactPixmap;
|
||||
QPixmap mContactPixmap;
|
||||
QLineEdit *mContactRawNbrEdit;
|
||||
QLineEdit *mContactNameEdit;
|
||||
QLineEdit *mContactNbrEdit;
|
||||
QLabel *mContactPixmapLabel;
|
||||
QPushButton *mSelectContactPicBtn;
|
||||
QPushButton *mNewContactBtn;
|
||||
QPushButton *mSaveContactBtn;
|
||||
QPushButton *mDeleteContactBtn;
|
||||
|
||||
|
||||
QPushButton *mDoneButton;
|
||||
|
||||
unsigned int SetSettingsData(CSettings *SettingsData);
|
||||
int UpdateContacts();
|
||||
void ClearTable();
|
||||
int GetCurSelectedItemIndexInTable();
|
||||
|
||||
public slots:
|
||||
void TabBarClicked(int);
|
||||
void RetreiveDIDButtonClicked(bool);
|
||||
void DIDsListFetched(QStringList);
|
||||
void DoneButtonClicked(bool);
|
||||
|
||||
void SelectContactPicClicked(bool checked);
|
||||
void SaveContactClicked(bool checked);
|
||||
void NewContactClicked(bool checked);
|
||||
void DeleteContactClicked(bool checked);
|
||||
void TableDoubleClicked(int,int);
|
||||
void TableCellSelected(/*int,int*/);
|
||||
};
|
||||
|
||||
#endif // CSETTINGSWINDOW_H
|
||||
|
||||
@ -18,6 +18,7 @@ CMasterCtrl::CMasterCtrl()
|
||||
|
||||
mEthernetNetworkServer = new CEthernetNetworkServer;
|
||||
mNetworkDevicesManager = new CNetworkDevicesMgr;
|
||||
mContactsRepository = new CContactRepository;
|
||||
|
||||
// mMasterCtrlSettings = new CSettings;
|
||||
}
|
||||
@ -33,6 +34,7 @@ CMasterCtrl::~CMasterCtrl()
|
||||
delete mSettingsWindow;
|
||||
delete mNetworkDevicesManager;
|
||||
delete mEthernetNetworkServer;
|
||||
delete mContactsRepository;
|
||||
// delete mMasterCtrlSettings;
|
||||
}
|
||||
|
||||
@ -51,7 +53,10 @@ void CMasterCtrl::Start()
|
||||
// FrameBuffer.seek(0);
|
||||
|
||||
|
||||
mContactsRepository->LoadContacts();
|
||||
|
||||
mNetworkDevicesManager->mVoipMSInterfaceHandle = mVoipMsSMSClient;
|
||||
mNetworkDevicesManager->mContactRepositoryHandle = mContactsRepository;
|
||||
mNetworkDevicesManager->mProgramHandle = this;
|
||||
mEthernetNetworkServer->mDevicesMgrHandle = mNetworkDevicesManager;
|
||||
mEthernetNetworkServer->mProgramHandle = this;
|
||||
@ -69,6 +74,8 @@ void CMasterCtrl::Start()
|
||||
mNetworkDevicesManager->InitNetworkDevices();
|
||||
mEthernetNetworkServer->StartServer(2182);
|
||||
|
||||
|
||||
|
||||
// mAppWidget.show();
|
||||
|
||||
|
||||
@ -82,6 +89,7 @@ unsigned int CMasterCtrl::QuitApplicationRequest()
|
||||
|
||||
unsigned int CMasterCtrl::ShowSettingsWindowRequest()
|
||||
{
|
||||
mSettingsWindow->UpdateContacts();
|
||||
mSettingsWindow->show();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include "ProgramSettings.h"
|
||||
#include "NetworkDevicesMgr.h"
|
||||
#include "EthernetNetworkServer.h"
|
||||
#include "ContactRepository.h"
|
||||
//#include "AppIconWidget.h"
|
||||
|
||||
class CMasterCtrl : public QObject
|
||||
@ -28,6 +29,7 @@ public:
|
||||
CProgramSettings mSettingsManager;
|
||||
CNetworkDevicesMgr *mNetworkDevicesManager;
|
||||
CEthernetNetworkServer *mEthernetNetworkServer;
|
||||
CContactRepository *mContactsRepository;
|
||||
// CAppIconWidget mAppWidget;
|
||||
|
||||
|
||||
@ -42,6 +44,8 @@ public:
|
||||
|
||||
int NewSMSMessagesArrived(QList<CSMSMessage> NewMessages);
|
||||
|
||||
CContactRepository *GetContactRepository(){return mContactsRepository;}
|
||||
|
||||
|
||||
//Modules requests...
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ int CNetworkDevicesMgr::CreateNewSMSDevice(int Address, CAbstractNetworkCommIF *
|
||||
|
||||
|
||||
CSMSDevice *SMSDevice = new CSMSDevice(Address,NetworkIF,mVoipMSInterfaceHandle);
|
||||
SMSDevice->mContactRepositoryHandle = mContactRepositoryHandle;
|
||||
|
||||
mNetworkDevicesList.append((CNetworkDevice*)SMSDevice);
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
class CVoipMsSMSClient;
|
||||
class CMasterCtrl;
|
||||
class CContactRepository;
|
||||
class CNetworkDevicesMgr: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -26,6 +27,7 @@ public:
|
||||
CNetworkDevice *GetDevice(int DeviceID, int Address);
|
||||
|
||||
CVoipMsSMSClient *mVoipMSInterfaceHandle;
|
||||
CContactRepository *mContactRepositoryHandle;
|
||||
CMasterCtrl *mProgramHandle;
|
||||
|
||||
int NewSMSMessagesReceived(QList<CSMSMessage> NewMessages);
|
||||
|
||||
@ -131,6 +131,9 @@ enum SMS_CLIENT_CMDS
|
||||
SMS_CLIENT_DEVICE_NEW_MSG_NOTIFICATION, //8
|
||||
SMS_CLIENT_DEVICE_SEND_SMS_REQUEST,
|
||||
SMS_CLIENT_DEVICE_SEND_SMS_ACK, //10
|
||||
SMS_CLIENT_DEVICE_GET_CONTACTS_REQUEST,
|
||||
SMS_CLIENT_DEVICE_GET_CONTACTS_RESPONSE,//12
|
||||
SMS_CLIENT_DEVICE_CONTACTS_CHANGED_NOTIFICATION,
|
||||
|
||||
SMS_CLIENT_DEVICE_MAX_MSG
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include "SMSDevice.h"
|
||||
#include "ProtocolDefs.h"
|
||||
#include <QBuffer>
|
||||
|
||||
#include "Contact.h"
|
||||
|
||||
CSMSDevice::CSMSDevice(int Address, CAbstractNetworkCommIF *NetworkInterface, CVoipMsSMSClient *VoipMsIFPtr):
|
||||
CNetworkDevice(ID_SMS_CLIENT,Address,NetworkInterface)
|
||||
@ -113,11 +113,35 @@ int CSMSDevice::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, int Mess
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
case SMS_CLIENT_DEVICE_GET_CONTACTS_REQUEST:
|
||||
{
|
||||
QByteArray FrameData;
|
||||
QBuffer FrameBuffer(&FrameData);
|
||||
FrameBuffer.open(QIODevice::ReadWrite);
|
||||
QDataStream *FrameDataStrm = new QDataStream(&FrameBuffer);
|
||||
|
||||
QList<CContact> *ContactsList = mContactRepositoryHandle->GetContacts();
|
||||
*FrameDataStrm << ContactsList->size();
|
||||
for(int i = 0; i < ContactsList->size(); i++)
|
||||
{
|
||||
*FrameDataStrm << ContactsList->at(i);
|
||||
}
|
||||
|
||||
FrameBuffer.seek(0);
|
||||
mNetworkInterfacePtr->SendNetworkMessage(mDeviceID,mDeviceAddress,SMS_CLIENT_DEVICE_GET_CONTACTS_RESPONSE,FrameData.size(),FrameData);
|
||||
|
||||
FrameBuffer.close();
|
||||
delete FrameDataStrm;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
case SMS_CLIENT_DEVICE_STATUS_REQUEST:
|
||||
case SMS_CLIENT_DEVICE_DID_INFO_RESPONSE:
|
||||
case SMS_CLIENT_DEVICE_NEW_MSG_NOTIFICATION:
|
||||
case SMS_CLIENT_DEVICE_GET_ALL_MSG_RESPONSE:
|
||||
case SMS_CLIENT_DEVICE_GET_CONTACTS_RESPONSE:
|
||||
default:
|
||||
{
|
||||
qDebug("SMSDevice Rx invalid MSG %d",MessageID);
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "GlobalDefine.h"
|
||||
#include "NetworkDevice.h"
|
||||
#include "VoipMsSMSClient.h"
|
||||
#include "ContactRepository.h"
|
||||
#include <QObject>
|
||||
|
||||
|
||||
@ -18,6 +19,7 @@ public:
|
||||
virtual int NewDeviceFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data);
|
||||
|
||||
CVoipMsSMSClient *mVoipMsInterfaceHandle;
|
||||
CContactRepository *mContactRepositoryHandle;
|
||||
QTimer *mStatusRequestTimer;
|
||||
int mStatusRequestsCount;
|
||||
|
||||
|
||||
@ -136,6 +136,7 @@ int CVoipMsSMSClient::DownloadNewSMS()
|
||||
|
||||
int CVoipMsSMSClient::CheckForNewSMS()
|
||||
{
|
||||
// qDebug("Check new SMS");
|
||||
if(mSMSMessagesList.isEmpty() == true)
|
||||
{
|
||||
return RET_ERROR;
|
||||
@ -310,6 +311,7 @@ unsigned int CVoipMsSMSClient::SMSReceived(QJsonArray *SMSArray)
|
||||
|
||||
NewMessages.append(mSMSMessagesList);
|
||||
mSMSMessagesList = NewMessages;
|
||||
StartSMSCheckTimer();
|
||||
|
||||
}
|
||||
else
|
||||
@ -335,6 +337,7 @@ unsigned int CVoipMsSMSClient::SMSReceived(QJsonArray *SMSArray)
|
||||
}
|
||||
}
|
||||
mSMSMessagesList.append(NewMessages);
|
||||
StartSMSCheckTimer();
|
||||
if(mFirstDownloadDone == true && NewMessages.size() > 0)
|
||||
{
|
||||
mProgramHandle->NewSMSMessagesArrived(NewMessages);
|
||||
@ -504,12 +507,14 @@ void CVoipMsSMSClient::StartSMSCheckTimer()
|
||||
{
|
||||
if(mFirstDownloadDone == true)
|
||||
{
|
||||
//qDebug("Timer started");
|
||||
mCheckNewSMSTimer->start(VOIP_MS_SMS_CHECK_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
void CVoipMsSMSClient::StopSMSCheckTimer()
|
||||
{
|
||||
//qDebug("Timer Stopped");
|
||||
mCheckNewSMSTimer->stop();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user