示例#1
0
文件: list.c 项目: rlaput/atm-machine
List * newList(){
    List* list = (List *) calloc(1,sizeof(List));
    list->head = newAccount();
    list->tail = newAccount();
    list->size = 0;
    list->head->next = list->tail;
    list->tail->prev = list->head;
    return list;
}
示例#2
0
// Loads the file of the client.
void BankAccount::loadFile()
{
	file.open(fileName, ios::in);
	char answer;

	// Iterates if the bank doesn't have a file
	// associated with the client.
	if (!file)
	{
		cout << "File does not exist.\n";
		cout << "Do you wish to create your file? (Y/N) ";
		cin >> answer;

		// Iterates if the bank wants to create a file.
		if (toupper(answer) == 'Y')
		{	
			file.open(fileName, ios::out);
			file.close();

			newAccount();
		}

		// Else iterates if the bank does NOT want to
		// create a file for the client.
		else
		{
			cout << "Reverting to main menu.\n";
			LogIn::mainMenu();
		}	
	}
示例#3
0
LoginWidget::LoginWidget(QWidget *parent,MsvEnvironment* environment)
     : QWidget(parent)
{
	this->environment = environment;
	loginEdit = new QLineEdit;
	loginLabel = new QLabel(tr("Username :"******"Password :"******"Login"));
    connect(connectButton, SIGNAL(clicked()), this, SLOT(login()));
    newAccountButton = new QPushButton(tr("Create account"));
    connect(newAccountButton, SIGNAL(clicked()), this, SLOT(newAccount()));

    mainLayout->addWidget(connectButton,2,0);
    mainLayout->addWidget(newAccountButton,2,1);

    setLayout(mainLayout);
    setWindowTitle(tr("Please login"));

    loginService = environment->getServiceHolder()->getLoginService();
}
示例#4
0
void MenuScene::onKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode)
{
    if (sym == SDLK_ESCAPE)
    {
        onExit();
    }

    if( sym == SDLK_F1) enterPlayGround();

    if (sym == SDLK_RETURN)
    {
        switch (menuFocus)
        {
        case LOGIN:
            login();
            break;
        case NEW_ACCOUNT:
#ifdef DEF_MAKEACCOUNT
            newAccount();
#endif
            break;
        case EXIT:
            onExit();
            break;
        }
    }

    if (sym == SDLK_UP)
    {
        switch (menuFocus)
        {
        case LOGIN:
            menuFocus = EXIT;
            break;
        case NEW_ACCOUNT:
            menuFocus = LOGIN;
            break;
        case EXIT:
            menuFocus = NEW_ACCOUNT;
            break;
        }
    }

    if (sym == SDLK_DOWN || sym == SDLK_TAB)
    {
        switch (menuFocus)
        {
        case LOGIN:
            menuFocus = NEW_ACCOUNT;
            break;
        case NEW_ACCOUNT:
            menuFocus = EXIT;
            break;
        case EXIT:
            menuFocus = LOGIN;
            break;
        }
    }
}
示例#5
0
文件: list.c 项目: rlaput/atm-machine
void writeFile(List* list, char* fileName){
    FILE* ofp = fopen(fileName, "w");
    Account* a = newAccount();
    a = list->head->next;
    while(a != list->tail){
        fprintf(ofp, "%s %d %d %f\n", a->name, a-> accountNum, a->accountPin, a->balance);
        a = a->next;
    }
    fclose(ofp);
}
示例#6
0
文件: list.c 项目: rlaput/atm-machine
void readFile(List* list,char* fileName){
    FILE* ifp = fopen(fileName, "r");
    while(!feof(ifp)){
        Account* a = newAccount();
        if(fscanf(ifp, "%s %d %d %f", a->name, &a->accountNum, &a->accountPin, &a->balance) != 4)
            break;
        addAccount(list, a);
    }
    fclose(ifp);
}
示例#7
0
void MenuScene::onLButtonDown(int x, int y)
{
    if (x > 385 && x < (385 + 164)) // Login Button
    {
        if (y > 178 && y < (178 + 22))
            login();

#ifdef DEF_MAKEACCOUNT
        if (y > 216 && y < (216 + 22))
            newAccount();
#endif

        if (y > 255 && y < (255 + 22))
            onExit();
    }
}
示例#8
0
文件: Bank.cpp 项目: wijagels/CS240
int Bank::cmdLoop() {
    while(true) {
        std::string arg;
        std::cout << "Choose from ['New', 'Login', 'Save', 'Load', 'Quit']" << std::endl << "$ ";
        std::getline(std::cin, arg);
        // Don't go nuts when C-d is pressed
        if(std::cin.eof()) {
            return 0;
        }
        if(arg == "Quit") {
            while(true) {
                std::cout << "Save before quitting? [yes/no]" << std::endl;
                std::string ans;
                getline(std::cin, ans);
                if(ans == "no")
                    return 0;
                else if(ans == "yes") {
                    save();
                    return 0;
                }
            }
        }
        else if(arg == "New") {
            newAccount();
        }
        else if(arg == "Login") {
            login();
        }
        else if(arg == "Save") {
            save();
        }
        else if(arg == "Load") {
            load();
        }
        else {
            std::cout << "Invalid command!" << std::endl;
        }
    }
    return 1;
}
示例#9
0
void FSHost::generalEventHandler(QSharedPointer<switch_event_t>event)
{
    QString uuid = switch_event_get_header_nil(event.data(), "Unique-ID");

    emit newEvent(event);

    switch(event.data()->event_id) {
    case SWITCH_EVENT_CHANNEL_CREATE: /*1A - 17B*/
        {
            eventChannelCreate(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_ANSWER: /*2A - 31B*/
        {
            eventChannelAnswer(event, uuid);
            break;
        }
    case SWITCH_EVENT_CODEC:/*3/4A - 24/25B*/
        {
            eventCodec(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_STATE:/*6/7/8/37/44/46A - 20/21/22/28/38/40/42B*/
        {
            eventChannelState(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_EXECUTE:/*9/11/13/15A*/
        {
            eventChannelExecute(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE:/*10/12/14/16/35A*/
        {
            eventChannelExecuteComplete(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_OUTGOING:/*18B*/
        {
            eventChannelOutgoing(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_ORIGINATE:/*19B*/
        {
            eventChannelOriginate(event, uuid);
            break;
        }
    case SWITCH_EVENT_CALL_UPDATE:/*23/29/30B*/
        {
            eventCallUpdate(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_PROGRESS:
        {
            eventChannelProgress(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA:/*26B*/
        {
            eventChannelProgressMedia(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_BRIDGE:/*27A*/
        {
            eventChannelBridge(event, uuid);
            break;
        }
    /*32?*/
    /*case SWITCH_EVENT_RECV_INFO:
        {
            eventRecvInfo(event, uuid);
            break;
        }*/
    case SWITCH_EVENT_CHANNEL_HANGUP:/*36A-33B*/
        {
            eventChannelHangup(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_UNBRIDGE:/*34A*/
        {
            eventChannelUnbridge(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE:/*39/43B*/
        {
            eventChannelHangupComplete(event, uuid);
            break;
        }
    case SWITCH_EVENT_CHANNEL_DESTROY:/*45A-41B*/
        {
            eventChannelDestroy(event, uuid);
            break;
        }
    case SWITCH_EVENT_CUSTOM:/*5A*/
        {
            if (strcmp(event.data()->subclass_name, "sofia::gateway_state") == 0)
            {
                QString state = switch_event_get_header_nil(event.data(), "State");
                QString gw = switch_event_get_header_nil(event.data(), "Gateway");
                QSharedPointer<Account> acc = _accounts.value(gw);
                if (acc.isNull())
                    return;

                if (state == "TRYING") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_TRYING);
                    emit accountStateChange(acc);
                } else if (state == "REGISTER") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_REGISTER);
                    emit accountStateChange(acc);
                } else if (state == "REGED") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_REGED);
                    emit accountStateChange(acc);
                } else if (state == "UNREGED") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_UNREGED);
                    emit accountStateChange(acc);
                } else if (state == "UNREGISTER") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_UNREGISTER);
                    emit accountStateChange(acc);
                } else if (state =="FAILED") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_FAILED);
                    emit accountStateChange(acc);
                } else if (state == "FAIL_WAIT") {
                    acc.data()->setState(FSCOMM_GW_STATE_FAIL_WAIT);
                    emit accountStateChange(acc);
                } else if (state == "EXPIRED") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_EXPIRED);
                    emit accountStateChange(acc);
                } else if (state == "NOREG") {
                    acc.data()->setStatusPhrase(switch_event_get_header_nil(event.data(), "Phrase"));
                    acc.data()->setState(FSCOMM_GW_STATE_NOREG);
                    emit accountStateChange(acc);
                }
            }
            else if (strcmp(event.data()->subclass_name, "sofia::gateway_add") == 0)
            {
                QString gw = switch_event_get_header_nil(event.data(), "Gateway");
                Account * accPtr = new Account(gw);
                QSharedPointer<Account> acc = QSharedPointer<Account>(accPtr);
                acc.data()->setState(FSCOMM_GW_STATE_NOAVAIL);
                _accounts.insert(gw, acc);
                emit newAccount(acc);
            }
            else if (strcmp(event.data()->subclass_name, "sofia::gateway_delete") == 0)
            {
                QSharedPointer<Account> acc = _accounts.take(switch_event_get_header_nil(event.data(), "Gateway"));
                if (!acc.isNull())
                    emit delAccount(acc);
            }
            else
            {
                //printEventHeaders(event);
            }
            break;
        }
    case SWITCH_EVENT_MODULE_LOAD:
        {
            QString modType = switch_event_get_header_nil(event.data(), "type");
            QString modKey = switch_event_get_header_nil(event.data(), "key");
            emit loadedModule(modType, modKey);
            break;
        }
    default:
        break;
    }
}
void MWidgetAvialability::onReadyLoad(Tp::PendingOperation *op)
{
    Q_UNUSED(op);

    mAccSet = mAM->validAccounts();

    foreach (Tp::AccountPtr account, mAccSet->accounts())
        if (!account->cmName().count(QRegExp("ring|mmscm")))
        {
            connect(account->becomeReady(),
                    SIGNAL(finished(Tp::PendingOperation*)),
                    SLOT(onAccountReady(Tp::PendingOperation*)));
        }

    connect(mAM.data(),
            SIGNAL(newAccount(Tp::AccountPtr)),
            SLOT(onNewAccount(Tp::AccountPtr)));
}

void MWidgetAvialability::onNewAccount(Tp::AccountPtr newaccount)
{
    connect(newaccount->becomeReady(),
            SIGNAL(finished(Tp::PendingOperation*)),
            SLOT(onAccountReady(Tp::PendingOperation*)));
}

void MWidgetAvialability::onAccountReady(Tp::PendingOperation *op)
{
    Tp::AccountPtr account = Tp::AccountPtr::staticCast(op->object());
    AccountWrapper *wrapper = new AccountWrapper(this, account);
    m_mainLayout->addItem(wrapper);
示例#11
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    preferences(NULL),
    _consoleWindow(NULL),
    _stateDebugDialog(NULL)

{
    ui->setupUi(this);

    /* Setup the taskbar icon */
    sysTray = new QSystemTrayIcon(QIcon(":/images/taskbar_icon"), this);
    sysTray->setToolTip(tr("FSComm"));

    /* Connect DTMF buttons */
    dialpadMapper = new QSignalMapper(this);
    connect(ui->dtmf0Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmf1Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmf2Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmf3Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmf4Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmf5Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmf6Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmf7Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmf8Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmf9Btn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmfABtn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmfBBtn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmfCBtn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmfDBtn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmfAstBtn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    connect(ui->dtmfPoundBtn, SIGNAL(clicked()), dialpadMapper, SLOT(map()));
    dialpadMapper->setMapping(ui->dtmf0Btn, QString("0"));
    dialpadMapper->setMapping(ui->dtmf1Btn, QString("1"));
    dialpadMapper->setMapping(ui->dtmf2Btn, QString("2"));
    dialpadMapper->setMapping(ui->dtmf3Btn, QString("3"));
    dialpadMapper->setMapping(ui->dtmf4Btn, QString("4"));
    dialpadMapper->setMapping(ui->dtmf5Btn, QString("5"));
    dialpadMapper->setMapping(ui->dtmf6Btn, QString("6"));
    dialpadMapper->setMapping(ui->dtmf7Btn, QString("7"));
    dialpadMapper->setMapping(ui->dtmf8Btn, QString("8"));
    dialpadMapper->setMapping(ui->dtmf9Btn, QString("9"));
    dialpadMapper->setMapping(ui->dtmfABtn, QString("A"));
    dialpadMapper->setMapping(ui->dtmfBBtn, QString("B"));
    dialpadMapper->setMapping(ui->dtmfCBtn, QString("C"));
    dialpadMapper->setMapping(ui->dtmfDBtn, QString("D"));
    dialpadMapper->setMapping(ui->dtmfAstBtn, QString("*"));
    dialpadMapper->setMapping(ui->dtmfPoundBtn, QString("#"));
    connect(dialpadMapper, SIGNAL(mapped(QString)), this, SLOT(sendDTMF(QString)));

    /* Connect events related to FreeSWITCH */
    connect(g_FSHost, SIGNAL(ready()),this, SLOT(fshostReady()));
    connect(g_FSHost, SIGNAL(ringing(QSharedPointer<Call>)), this, SLOT(ringing(QSharedPointer<Call>)));
    connect(g_FSHost, SIGNAL(answered(QSharedPointer<Call>)), this, SLOT(answered(QSharedPointer<Call>)));
    connect(g_FSHost, SIGNAL(hungup(QSharedPointer<Call>)), this, SLOT(hungup(QSharedPointer<Call>)));
    connect(g_FSHost, SIGNAL(newOutgoingCall(QSharedPointer<Call>)), this, SLOT(newOutgoingCall(QSharedPointer<Call>)));
    connect(g_FSHost, SIGNAL(callFailed(QSharedPointer<Call>)), this, SLOT(callFailed(QSharedPointer<Call>)));
    connect(g_FSHost, SIGNAL(accountStateChange(QSharedPointer<Account>)), this, SLOT(accountStateChanged(QSharedPointer<Account>)));
    connect(g_FSHost, SIGNAL(newAccount(QSharedPointer<Account>)), this, SLOT(accountAdd(QSharedPointer<Account>)));
    connect(g_FSHost, SIGNAL(delAccount(QSharedPointer<Account>)), this, SLOT(accountDel(QSharedPointer<Account>)));
    connect(g_FSHost, SIGNAL(coreLoadingError(QString)), this, SLOT(coreLoadingError(QString)));

    /* Connect call commands */
    connect(ui->newCallBtn, SIGNAL(clicked()), this, SLOT(makeCall()));
    connect(ui->answerBtn, SIGNAL(clicked()), this, SLOT(paAnswer()));
    connect(ui->hangupBtn, SIGNAL(clicked()), this, SLOT(paHangup()));
    connect(ui->recoredCallBtn, SIGNAL(toggled(bool)), SLOT(recordCall(bool)));
    connect(ui->btnHold, SIGNAL(toggled(bool)), this, SLOT(holdCall(bool)));
    /*connect(ui->btnTransfer, SIGNAL(clicked()), this, SLOT(transferCall()));*/
    connect(ui->tableCalls, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(callTableDoubleClick(QTableWidgetItem*)));
    connect(ui->action_Preferences, SIGNAL(triggered()), this, SLOT(prefTriggered()));
    connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionConsole, SIGNAL(triggered()), this, SLOT(debugConsoleTriggered()));
    connect(ui->actionEvents, SIGNAL(triggered()), this, SLOT(debugEventsTriggered()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
    connect(ui->actionSetDefaultAccount, SIGNAL(triggered(bool)), this, SLOT(setDefaultAccount()));
    connect(sysTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(sysTrayActivated(QSystemTrayIcon::ActivationReason)));

    /* Set the context menus */
    ui->tableAccounts->addAction(ui->actionSetDefaultAccount);

    /* Set other properties */
    ui->tableAccounts->horizontalHeader()->setStretchLastSection(true);

    /* Set the call timer */
    callTimer = new QTimer(this);
    callTimer->setInterval(1000);
    connect(callTimer, SIGNAL(timeout()), this, SLOT(updateCallTimers()));
    callTimer->start();
}