📄 smsconfig.cpp
字号:
/* * Written By S砤womir Szczyrba <steev@hot.pl> * All rights reserved. No warrenties, use at your own risk. * This source is distributed under the GNU GENERAL PUBLIC LICENCE, * see the file "COPYING" for more information. */#include "SMSConfig.h"#include "SMSConfigIco.h"#include <iostream>using namespace std;#ifdef WIN32#define FNAME "sms.ini"#else#define FNAME ".smsrc"#endifSMSConfig::SMSConfig(FXApp * app):FXWizard(app,"Konfiguracja",NULL,DECOR_TITLE|DECOR_BORDER|LAYOUT_FILL,0,0,200,200){ icon = new FXPNGIcon(app,ConfigMoose); setImage(icon);//proxy i podpis FXGroupBox* frame = new FXGroupBox(getContainer(),"Ustawienia og髄ne",LAYOUT_FILL|FRAME_RIDGE,0,0,0,0, 10,10,0,0); new FXLabel(frame,"Podpis:"); signature = new FXTextField(frame,0,NULL,0,TEXTFIELD_NORMAL|LAYOUT_FILL_X); new FXSeparator(frame,SEPARATOR_RIDGE|LAYOUT_FILL_X,0,0,0,0,0,0,15,5); new FXLabel(frame,"Adres serwera PROXY:"); proxyAddress = new FXTextField(frame,0,NULL,0,TEXTFIELD_NORMAL|LAYOUT_FILL_X); new FXLabel(frame,"Port serwera PROXY:"); proxyPort = new FXTextField(frame,0,NULL,0,TEXTFIELD_INTEGER|TEXTFIELD_NORMAL|LAYOUT_FILL_X); proxy = new FXCheckButton(frame,"Korzystaj z serwera PROXY");//Bramka ery frame = new FXGroupBox(getContainer(),"Ustawienia bramki ERA GSM",LAYOUT_FILL|FRAME_RIDGE,0,0,0,0, 10,10,0,0); new FXLabel(frame,"Login do darmowej bramki ERA/Omnix:"); eraLogin = new FXTextField(frame,0,NULL,0,TEXTFIELD_NORMAL|LAYOUT_FILL_X); new FXLabel(frame,"Has硂:"); eraPass = new FXTextField(frame,0,NULL,0,TEXTFIELD_NORMAL|LAYOUT_FILL_X|TEXTFIELD_PASSWD);//Bramka MiastaPlusa frame = new FXGroupBox(getContainer(),"Ustawienia bramki MIASTO PLUSA",LAYOUT_FILL|FRAME_RIDGE,0,0,0,0, 10,10,0,0); new FXLabel(frame,"Login do bramki Miasto Plusa:"); miastoLogin = new FXTextField(frame,0,NULL,0,TEXTFIELD_NORMAL|LAYOUT_FILL_X); new FXLabel(frame,"Has硂:"); miastoPass = new FXTextField(frame,0,NULL,0,TEXTFIELD_NORMAL|LAYOUT_FILL_X|TEXTFIELD_PASSWD);//plik konfiguracyjny. file = FXFile::getHomeDirectory() +"/"+ FNAME; era16 = new FXPNGIcon(app,era16_png); heyah16 = new FXPNGIcon(app,heyah16_png); plus16 = new FXPNGIcon(app,plus16_png); idea16 = new FXPNGIcon(app,idea16_png); swoi16 = new FXPNGIcon(app,samiswoi16_png); era16->create(); heyah16->create(); plus16->create(); idea16->create(); swoi16->create(); config = new FXSettings(); config->parseFile(file,TRUE); finish->setText("&Zako馽z"); cancel->setText("&Anuluj"); retreat->setText("&Cofnij"); advance->setText("&Dalej"); }SMSConfig::~SMSConfig(){ config->unparseFile(file); delete config; delete era16; delete heyah16; delete plus16; delete idea16; delete swoi16; delete icon;}FXuint SMSConfig::execute(FXuint placement) { FXuint runOK; FXuint px; FXStringDict * dict = config->find("KONFIGURACJA"); if(dict) { signature->setText(config->readStringEntry ("KONFIGURACJA","podpis")); proxyAddress->setText(config->readStringEntry("KONFIGURACJA","proxy adres")); proxyPort->setText(config->readStringEntry ("KONFIGURACJA","proxy port")); eraLogin->setText(config->readStringEntry ("KONFIGURACJA","era login")); eraPass->setText(config->readStringEntry ("KONFIGURACJA","era haslo")); miastoLogin->setText(config->readStringEntry ("KONFIGURACJA","miasto login")); miastoPass->setText(config->readStringEntry ("KONFIGURACJA","miasto haslo")); px=config->readUnsignedEntry ("KONFIGURACJA","proxy"); if (px) { proxy->setCheck(TRUE);} else { proxy->setCheck(FALSE);} } runOK = FXWizard::execute(placement); if (runOK) { config->writeStringEntry ("KONFIGURACJA","podpis",signature->getText().text()); config->writeStringEntry ("KONFIGURACJA","era login",eraLogin->getText().text()); config->writeStringEntry ("KONFIGURACJA","era haslo",eraPass->getText().text()); config->writeStringEntry ("KONFIGURACJA","miasto login",miastoLogin->getText().text()); config->writeStringEntry ("KONFIGURACJA","miasto haslo",miastoPass->getText().text()); config->writeStringEntry ("KONFIGURACJA","proxy adres",proxyAddress->getText().text()); config->writeStringEntry ("KONFIGURACJA","proxy port",proxyPort->getText().text()); config->writeUnsignedEntry("KONFIGURACJA","proxy",proxy->getCheck()?1:0); config->unparseFile(file); } return runOK;}void SMSConfig::savePos(FXuint x,FXuint y) { config->writeUnsignedEntry("KONFIGURACJA","pozycja_x",x); config->writeUnsignedEntry("KONFIGURACJA","pozycja_y",y);}void SMSConfig::loadPos(FXuint& x,FXuint& y) { x = config->readUnsignedEntry("KONFIGURACJA","pozycja_x",100); y = config->readUnsignedEntry("KONFIGURACJA","pozycja_y",100);}FXString SMSConfig::getValue(FXString item) { return config->readStringEntry("KONFIGURACJA",item.text()); }FXString SMSConfig::getPhone(FXString name) { return config->readStringEntry("TELEFONY",name.text()); } FXint SMSConfig::isName(FXString name) { return config->existingEntry("TELEFONY",name.text()); }FXint SMSConfig::setPhone(FXString name, FXString phone) { FXint ok; if (isName(name)) { return 0; } if ((ok=config->writeStringEntry("TELEFONY",name.text(),phone.text()))){ config->unparseFile(file); } return ok;} FXint SMSConfig::delPhone(FXString name) { FXint ok; if ((ok=config->deleteEntry("TELEFONY",name.text()))) { config->unparseFile(file); } return ok;}void SMSConfig::readPhones(FXList * list) { FXString name,phone; FXint network,pos; SMSNet net; FXStringDict * dict = config->find("TELEFONY"); if (dict) { list->clearItems(); pos=dict->first(); while(pos < dict->size()) { name=dict->key(pos); phone=getPhone(name); pos=dict->next(pos); network=net.numberOK(phone.text()); switch (network) { case NR_ERA: list->appendItem(name.text(),era16 ); break; case NR_HEYAH: list->appendItem(name.text(),heyah16); break; case NR_IDEA: list->appendItem(name.text(),idea16 ); break; case NR_PLUS: list->appendItem(name.text(),plus16 ); break; case NR_SAMISWOI: list->appendItem(name.text(),swoi16 ); break; default: cout << name.text() << " - " << phone.text() << "\n"; } } if (list->getNumItems()) { list->sortItems(); list->setCurrentItem(0); list->setAnchorItem(0); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -