Ejemplo n.º 1
0
void Systray::createActions()
{
    myAccountAction = new QAction(tr("&My Account"));
    connect(myAccountAction, SIGNAL(triggered()), this, SLOT(openAccount()));

    uploadFileAction = new QAction(tr("Upload &File..."));
    connect(uploadFileAction, SIGNAL(triggered()), this, SLOT(uploadFile()));

    uploadClipboardAction = new QAction(tr("Upload &Clipboard"));
    connect(uploadClipboardAction, SIGNAL(triggered()), this, SLOT(uploadClipboard()));

    fullScreenAction = new QAction(tr("Capture &Desktop"));
    connect(fullScreenAction, SIGNAL(triggered()), this, SLOT(fullScreenScreenshot()));

    selectAreaAction = new QAction(tr("Capture &Area"));
    connect(selectAreaAction, SIGNAL(triggered()), this, SLOT(selectAreaScreenshot()));

    activeAction = new QAction(tr("Capture Current &Window"));
    connect(activeAction, SIGNAL(triggered()), this, SLOT(activeWindowScreenshotTimed()));

    historyMenu = new QMenu(tr("&History"));

    settingsAction = new QAction(tr("&Settings..."));
    connect(settingsAction, SIGNAL(triggered()), this, SLOT(openSettings()));

    quitAction = new QAction(tr("&Quit"));
    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    openSaveDirectoryAction = new QAction(tr("&Open Screenshot Directory"));
    connect(openSaveDirectoryAction, SIGNAL(triggered()), this, SLOT(openSaveDirectory()));
}
Ejemplo n.º 2
0
void openAccount(Customer *customer, Account *account)
{
	int selection = 0;
	int tempNum;

	system("clear");
	cout << account->getName() << " : " << account->getTypeinString() << "\n";
	cout << "Balance: " << account->getBalance() << "\n\n";

	cout << "1. " << "Deposit Money\n";
	cout << "2. " << "Withdraw Money\n";
	cout << "3. " << "Go Back\n";
	cout << "\nOption #: ";

	cin >> selection;
	server.logData(customer, selection);

	if(selection == 1)
	{
		system("clear");
		cout << "How much would you like to deposit: ";
		cin >> tempNum;
		account->deposit(tempNum);
		server.logData(customer, tempNum);
		server.serialize();
		openAccount(customer, account);
	}
Ejemplo n.º 3
0
void clientHandler(int clientSocket)
{
    // connection error
    if(clientSocket < 0){
        printf("%s", "Error connecting to clientSocket.\n");
        exit(EXIT_FAILURE);
    }

    int in_session = -1;

    // read from client
    char buffer[256]; // buffer for socket messages
    while(1){
        bzero((void*) buffer, 256);
        if((read(clientSocket, buffer, 255)) <= 0){ // no response
            exit(EXIT_SUCCESS);
        }

        // parse command
        char *command = strtok(buffer, " \n");
        char *commandArg = strtok(NULL, " \n");

        if(strcmp(command, "open") == 0){ // open account
           openAccount(clientSocket, commandArg, &in_session);
        }
        else if(strcmp(command, "start") == 0){ // start account session
            startAccount(clientSocket, commandArg, &in_session);
        }
        else if(strcmp(command, "credit") == 0){ // credit account
            creditAccount(clientSocket, commandArg, &in_session);
        }
        else if(strcmp(command, "debit") == 0){ // debit account
            debitAccount(clientSocket, commandArg, &in_session);
        }
        else if(strcmp(command, "balance") == 0){ // get balance
            getBalance(clientSocket, &in_session);
        }
        else if(strcmp(command, "finish") == 0){ // finish
            finishSession(clientSocket, &in_session);
        }
        else{
            printf("%s", "Client done goofed, abort mission.");
            exit(EXIT_FAILURE);
        }
    }

    return;
}
Ejemplo n.º 4
0
/**
	选择相应的操作,按6退出系统
*/
void operation() {
	int choice; // 操作选择
	do {
		printf("**********欢迎来到坑钱银行*********\n");
		printf("选择以下操作:1、开户 2、存款 3、取款 4、转账 5、查询 6、退出系统\n");
		scanf("%d", &choice);
		switch(choice) {
			case 1: openAccount(); break;
			case 2: save(); break;
			case 3: getMoney(); break;
			case 4: transfer(); break;
			case 5: query(); break;
			default:break;
		}
	} while(choice != 6);
}
Ejemplo n.º 5
0
void Systray::doDoubleClickAction()
{
    if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::OPEN_UPLOADS)) {
        openSaveDirectory();
    } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::OPEN_SETTINGS)) {
        openSettings();
    } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::UPLOAD_FILE)) {
        uploadFile();
    } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::CAPTURE_DESKTOP)) {
        fullScreenScreenshot();
    } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::CAPTURE_AREA)) {
        selectAreaScreenshot();
    } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::CAPTURE_WINDOW)) {
        activeWindowScreenshotTimed();
    } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::OPEN_ACCOUNT)) {
        openAccount();
    } else {
        qDebug() << "Option not recognized";
    }
}
Ejemplo n.º 6
0
/**
* Processes the input from the client, given the command, argument, and state
* of the client. 
*
* The 'state' is simply whether or not the client is in a session.
* -1: Client wishes to exit
*  0: Client is connected, but is not in an account session
*  1: Client is connected and is in an account session
*
*/
int process_input(char *buffer, int state, client_t **client){
	
	int i;
	char *parsed = NULL;
	int len = strlen(buffer);
	for(i = 0; i < len; i++){
		if(buffer[i] == '\n'){
			if(i == 0){
				/*If it's just a newline*/
				break;
			}
			parsed = malloc(sizeof(char)*(i+1));
			strncpy(parsed, buffer, i);
			parsed[i] = '\0';
			break;
		}
	}
	if(parsed == NULL){
		printf("Error parsing buffer.\n");
		return state;
	}

	printf("CLIENT> %s\n", parsed);
	

	Node **list = &((*client)->head);

	char *command, *arg;
	char name[MAX_ARG_LEN];
	command = strtok(parsed, " ");
	arg = strtok(NULL, " ");
	memset(name, '\0', sizeof(name));
	if(arg != NULL){
		strcpy(name, arg);
	}


	if(strcmp(parsed, "exit") == 0){
		printf("Client exits!\n");
		if(state == 1){
			printf("Finishing customer session.\n");
			Node *node = findAccount((*client)->current_acc, *list);
			Account *acc = node->account;
			finishAccount(&acc, state);
			free((*client)->current_acc);
		}
		update_client_count(-1);
		free(parsed);
		return -1;
	}else if(strcmp(command, "open") == 0){
		if(state == 1){
			printf("Still in customer session!\n");
			free(parsed);
			return 1;
		}
		int open = openAccount(list, name);
		char *msg = "Account opened for ";
		printf("%s%s.\n", msg, name);
		if(open == -1){
			printf("Error opening account!\n");
			free(parsed);
			return 0;
		}
		free(parsed);
		return 0;
	}else if(strcmp(command, "start") == 0){
		if(state == 0){
			Node *ptr = findAccount(name, *list);
			if(ptr == NULL){
				free(parsed);
				return 0;
			}
			Account *acc = ptr->account;
			int n = startAccount(&acc, list);
			if(n == 0){
				printf("Account is still in use.\n");
				free(parsed);
				return 0;
			}
			char *current = malloc(strlen(name)*sizeof(char));
			strcpy(current, name);
			(*client)->current_acc = current;
			free(parsed);
			return 1;
		}else{
			printf("Still in session!\n");
			free(parsed);
			return 1;
		}
	}else if(strcmp(command, "credit") == 0){
		if(state == 1){
			float new = updateAccount((*client)->current_acc, list, atof(arg));
			printf("Balance of %s is now %.2f.\n", (*client)->current_acc, new);
			free(parsed);
			return 1;
		}else{
Ejemplo n.º 7
0
void NMainMenuBar::setupToolsMenu() {
    toolsMenu = this->addMenu(tr("&Tools"));
    QFont f = global.getGuiFont(QFont());
    toolsMenu->setFont(f);

    synchronizeAction = new QAction(tr("&Synchronize"), this);
    synchronizeAction->setToolTip(tr("Synchronize with Evernote"));
    connect(synchronizeAction, SIGNAL(triggered()), parent, SLOT(synchronize()));
    toolsMenu->addAction(synchronizeAction);

    disconnectAction = new QAction(tr("&Disconnect"), this);
    disconnectAction->setToolTip(tr("Disconnect from Evernote"));
    connect(disconnectAction, SIGNAL(triggered()), parent, SLOT(disconnect()));
    setupShortcut(disconnectAction, QString(""));
    toolsMenu->addAction(disconnectAction);
    disconnectAction->setEnabled(false);
    disconnectAction->setVisible(false);  /// We can probably delete this whole menu option

    pauseIndexingAction = new QAction(tr("Pause &indexing"), this);
    pauseIndexingAction->setToolTip(tr("Temporarily pause indexing"));
    setupShortcut(pauseIndexingAction, QString("Tools_Pause_Indexing"));
    connect(pauseIndexingAction, SIGNAL(triggered()), parent, SLOT(pauseIndexing()));
    pauseIndexingAction->setCheckable(true);
    toolsMenu->addAction(pauseIndexingAction);
    pauseIndexingAction->setVisible(global.enableIndexing);

    disableEditingAction = new QAction(tr("Disable &editing"), this);
    disableEditingAction->setToolTip(tr("Temporarily disable note editing"));
    setupShortcut(disableEditingAction, QString("Tools_Disable_Editing"));
    disableEditingAction->setCheckable(true);
    disableEditingAction->setChecked(global.disableEditing);
    connect(disableEditingAction, SIGNAL(triggered()), parent, SLOT(disableEditing()));
    toolsMenu->addAction(disableEditingAction);

    toolsMenu->addSeparator();

    reindexDatabaseAction = new QAction(tr("&Reindex database"), this);
    reindexDatabaseAction->setToolTip(tr("Reindex all notes"));
    setupShortcut(reindexDatabaseAction, QString("Tools_Database_Reindex"));
    connect(reindexDatabaseAction, SIGNAL(triggered()), parent, SLOT(reindexDatabase()));
    toolsMenu->addAction(reindexDatabaseAction);
    reindexDatabaseAction->setVisible(global.enableIndexing);

    databaseStatusDialogAction = new QAction(tr("&Database status"), this);
    databaseStatusDialogAction->setToolTip(tr("Database Status"));
    setupShortcut(databaseStatusDialogAction, QString("Tools_Database_Status"));
    connect(databaseStatusDialogAction, SIGNAL(triggered()), parent, SLOT(openDatabaseStatus()));
    toolsMenu->addAction(databaseStatusDialogAction);

    toolsMenu->addSeparator();

    accountDialogAction = new QAction(tr("A&ccount / usage"), this);
    accountDialogAction->setToolTip(tr("Account and usage information"));
    connect(accountDialogAction, SIGNAL(triggered()), parent, SLOT(openAccount()));
    setupShortcut(accountDialogAction, QString("Tools_Account_Information"));
    toolsMenu->addAction(accountDialogAction);

    toolsMenu->addSeparator();

    importFoldersDialogAction = new QAction(tr("&Import folders"), this);
    importFoldersDialogAction->setToolTip(tr("Import Folders"));
    setupShortcut(importFoldersDialogAction, QString("Tools_Import_Folders"));
    connect(importFoldersDialogAction, SIGNAL(triggered()), parent, SLOT(openImportFolders()));
    toolsMenu->addAction(importFoldersDialogAction);
}