Ejemplo n.º 1
0
NS_IMETHODIMP KDEWallet::SetLoginSavingEnabled(const nsAString & aHost,
        bool isEnabled) {
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::SetLoginSavingEnabled() Called") );

    nsresult res = checkWallet();
    NS_ENSURE_SUCCESS(res, res);

    QMap< QString, QString > saveDisabledHostMap;

    wallet->readMap( kSaveDisabledHostsMapName, saveDisabledHostMap );
    if( isEnabled ) { //Remove form disabled list, if it is there
        if( saveDisabledHostMap.contains( NSString2QtString(aHost) ) )
            if( saveDisabledHostMap.remove( NSString2QtString(aHost) ) != 1 ) {
                NS_ERROR("Can not remove save map information");
                return NS_ERROR_FAILURE;
            }
    }
    else 	// Add to disabled list
        saveDisabledHostMap[ NSString2QtString(aHost) ] = "TRUE";
    if( wallet->writeMap( kSaveDisabledHostsMapName, saveDisabledHostMap ) ) {
        NS_ERROR("Can not save map information");
        return NS_ERROR_FAILURE;
    }
    return NS_OK;
}
Ejemplo n.º 2
0
NS_IMETHODIMP KDEWallet::GetAllDisabledHosts(PRUint32 *aCount,
        PRUnichar ***aHostnames) {
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::GetAllDisabledHosts() Called") );
    *aCount = 0;

    nsresult res = checkWallet();
    NS_ENSURE_SUCCESS(res, res);

    QMap< QString, QString > saveDisabledHostMap;
    wallet->readMap( kSaveDisabledHostsMapName, saveDisabledHostMap );

    if( saveDisabledHostMap.count() == 0 )
        return NS_OK;

    PRUnichar **array = (PRUnichar **) nsMemory::Alloc(saveDisabledHostMap.count() * sizeof(PRUnichar *));
    NS_ENSURE_TRUE(array, NS_ERROR_OUT_OF_MEMORY);
    memset(array, 0, saveDisabledHostMap.count() * sizeof(PRUnichar*));

    QMapIterator< QString, QString > iterator(saveDisabledHostMap);
    int i = 0;
    while (iterator.hasNext()) {
        iterator.next();
        PRUnichar *nsHostname = NS_StringCloneData( QtString2NSString(iterator.key()) );

        if (!nsHostname)
            return NS_ERROR_FAILURE;

        NS_ENSURE_STATE(nsHostname);
        array[i] = nsHostname;
        i++;
    }
    *aCount = i;
    *aHostnames = array;
    return NS_OK;
}
Ejemplo n.º 3
0
NS_IMETHODIMP KDEWallet::RemoveAllLogins() {
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::RemoveAllLogins() Called") );

    nsresult res = checkWallet();
    NS_ENSURE_SUCCESS(res, res);

    QString key = generateQueryWalletKey( NS_ConvertUTF8toUTF16( "*" ), NS_ConvertUTF8toUTF16( "*" ),
                                          NS_ConvertUTF8toUTF16( "*" ), NS_ConvertUTF8toUTF16( "*" ) );

    QMap< QString, QMap< QString, QString > > entryMap;
    if( wallet->readMapList( key, entryMap ) != 0 )
        return NS_OK;
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::RemoveAllLogins() Found %d maps", entryMap.count() ) );
    if( entryMap.count() == 0 )
        return NS_OK;

    QMapIterator< QString, QMap< QString, QString > > iterator(entryMap);
    while (iterator.hasNext()) {
        iterator.next();
        if( wallet->removeEntry( iterator.key() ) ) {
            NS_ERROR("Can not remove correctly map information");
            return NS_ERROR_FAILURE;
        }
    }
    return NS_OK;
}
Ejemplo n.º 4
0
NS_IMETHODIMP KDEWallet::Init() {
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::Init() Called") );

    if (this->GetAppID().Equals(FIREFOX_APP_ID)) {
        mozillaApp = Firefox;
    } else if (this->GetAppID().Equals(THUNDERBIRD_APP_ID)) {
        mozillaApp = Thunderbird;
    } else {
        mozillaApp = Unknown;
    }
    InitDefaultPreferenceValues();

    /* KWallet requries a functioning KApplication or it will segfault */
    KAboutData* aboutData = NULL;
    switch(mozillaApp) {
    case Firefox:
        aboutData = new KAboutData("Firefox", NULL, ki18n("Firefox KWallet Plugin"), "" );
        break;
    case Thunderbird:
        aboutData = new KAboutData("Thunderbird", NULL, ki18n("Thunderbird KWallet Plugin"), "" );
        break;
    default:
        aboutData = new KAboutData("Unknown Mozilla Application", NULL, ki18n("Unknown Mozilla Application KWallet Plugin"), "" );
        break;
    }

    KCmdLineArgs::init( aboutData );
    app = new KApplication(false);

    nsresult res = checkWallet();
    NS_ENSURE_SUCCESS(res, res);

    return NS_OK;
}
Ejemplo n.º 5
0
NS_IMETHODIMP KDEWallet::CountLogins(const nsAString & aHostname,
                                     const nsAString & aActionURL,
                                     const nsAString & aHttpRealm,
                                     PRUint32 *_retval) {
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::CountLogins() Called") );
    *_retval = 0;

    nsresult res = checkWallet();
    NS_ENSURE_SUCCESS(res, res);

    QString key = generateQueryWalletKey( aHostname, aActionURL, aHttpRealm, NS_ConvertUTF8toUTF16( "*" ) );

    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::CountLogins() key: %s", key.toUtf8().data() ) );
    QMap< QString, QMap< QString, QString > > entryMap;
    if( wallet->readMapList( key, entryMap ) != 0 )
        return NS_OK;
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::CountLogins() Found %d maps", entryMap.count() ) );
    *_retval = entryMap.count();
    return NS_OK;
}
Ejemplo n.º 6
0
NS_IMETHODIMP KDEWallet::GetLoginSavingEnabled(const nsAString & aHost,
        bool *_retval) {
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::GetLoginSavingEnabled() Called") );

    nsresult res = checkWallet();
    NS_ENSURE_SUCCESS(res, res);

    QMap< QString, QString > saveDisabledHostMap;

    wallet->readMap( kSaveDisabledHostsMapName, saveDisabledHostMap );

    *_retval = true;
    if( saveDisabledHostMap.contains(  NSString2QtString(aHost) ) )
        *_retval = false;

    if( *_retval )
        PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::GetLoginSavingEnabled() saving for %s is enabled", NS_ConvertUTF16toUTF8(aHost).get() ) );
    else
        PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::GetLoginSavingEnabled() saving for %s is disabled", NS_ConvertUTF16toUTF8(aHost).get() ) );

    return NS_OK;
}
Ejemplo n.º 7
0
NS_IMETHODIMP KDEWallet::RemoveLogin(nsILoginInfo *aLogin) {
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::RemoveLogin() Called") );

    nsresult res = checkWallet();
    NS_ENSURE_SUCCESS(res, res);

    nsAutoString aUsername;
    aLogin->GetUsername(aUsername);
    nsAutoString aActionURL;
    aLogin->GetFormSubmitURL(aActionURL);
    nsAutoString aHttpRealm;
    aLogin->GetHttpRealm(aHttpRealm);
    nsAutoString aHostname;
    aLogin->GetHostname(aHostname);

    QString key = generateWalletKey( aHostname, aActionURL, aHttpRealm, aUsername );
    if( wallet->removeEntry( key ) ) {
        NS_ERROR("Can not remove correctly map information");
        return NS_ERROR_FAILURE;
    }
    return NS_OK;
}
Ejemplo n.º 8
0
void WalletView::createActions()
{
    QActionGroup *tabGroup = new QActionGroup(this);

    overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
    overviewAction->setStatusTip(tr("Show general overview of wallet"));
    overviewAction->setToolTip(overviewAction->statusTip());
    overviewAction->setCheckable(true);
    overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
    tabGroup->addAction(overviewAction);

    sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
    sendCoinsAction->setStatusTip(tr("Send coins to a HoboNickels address"));
    sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
    sendCoinsAction->setCheckable(true);
    sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
    tabGroup->addAction(sendCoinsAction);

    receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this);
    receiveCoinsAction->setStatusTip(tr("Show the list of addresses for receiving payments"));
    receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
    receiveCoinsAction->setCheckable(true);
    receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
    tabGroup->addAction(receiveCoinsAction);

    historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
    historyAction->setStatusTip(tr("Browse transaction history"));
    historyAction->setToolTip(historyAction->statusTip());
    historyAction->setCheckable(true);
    historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
    tabGroup->addAction(historyAction);

    addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
    addressBookAction->setStatusTip(tr("Edit the list of stored addresses and labels"));
    addressBookAction->setToolTip(addressBookAction->statusTip());
    addressBookAction->setCheckable(true);
    addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
    tabGroup->addAction(addressBookAction);

    charityAction = new QAction(QIcon(":/icons/send"), tr("Stake For &Charity"), this);
    charityAction->setStatusTip(tr("Enable Stake For Charity"));
    charityAction->setToolTip(charityAction->statusTip());
    charityAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
    charityAction->setCheckable(true);
    tabGroup->addAction(charityAction);


    connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));
    connect(charityAction, SIGNAL(triggered()), this, SLOT(charityClicked()));

    encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
    encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
    encryptWalletAction->setCheckable(true);

    unlockWalletAction = new QAction(QIcon(":/icons/lock_open"), tr("&Unlock Wallet..."), this);
    unlockWalletAction->setStatusTip(tr("Unlock the wallet for minting"));
    unlockWalletAction->setCheckable(true);

    lockWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Lock Wallet..."), this);
    lockWalletAction->setStatusTip(tr("Lock the wallet"));
    lockWalletAction->setCheckable(true);

    checkWalletAction = new QAction(QIcon(":/icons/inspect"), tr("&Check Wallet..."), this);
    checkWalletAction->setStatusTip(tr("Check wallet integrity and report findings"));

    repairWalletAction = new QAction(QIcon(":/icons/repair"), tr("&Repair Wallet..."), this);
    repairWalletAction->setStatusTip(tr("Fix wallet integrity and remove orphans"));

    backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
    backupWalletAction->setStatusTip(tr("Backup wallet to another location"));

    dumpWalletAction = new QAction(QIcon(":/icons/export"), tr("&Export Wallet..."), this);
    dumpWalletAction->setStatusTip(tr("Export a wallet's keys to a text file"));

    importWalletAction = new QAction(QIcon(":/icons/import"), tr("&Import Wallet..."), this);
    importWalletAction->setStatusTip(tr("Import keys from text file into wallet"));

    backupAllWalletsAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup All Wallets..."), this);
    backupAllWalletsAction->setStatusTip(tr("Backup all loaded wallets to another location"));

    changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
    changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));

    signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
    signMessageAction->setStatusTip(tr("Sign messages with your HoboNickels addresses to prove you own them"));

    verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);
    verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified HoboNickels addresses"));

    exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
    exportAction->setStatusTip(tr("Export the data in the current tab to a file"));
    exportAction->setToolTip(exportAction->statusTip());

    connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
    connect(checkWalletAction, SIGNAL(triggered()), this, SLOT(checkWallet()));
    connect(repairWalletAction, SIGNAL(triggered()), this, SLOT(repairWallet()));
    connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
    connect(dumpWalletAction, SIGNAL(triggered()), this, SLOT(dumpWallet()));
    connect(importWalletAction, SIGNAL(triggered()), this, SLOT(importWallet()));
    connect(backupAllWalletsAction, SIGNAL(triggered()), this, SLOT(backupAllWallets()));
    connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
    connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
    connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
    connect(unlockWalletAction, SIGNAL(triggered(bool)), this, SLOT(unlockWalletForMint()));
    connect(lockWalletAction, SIGNAL(triggered(bool)), this, SLOT(lockWallet()));
}
Ejemplo n.º 9
0
void BitcoinGUI::createActions()
{
    QActionGroup *tabGroup = new QActionGroup(this);

    overviewAction = new QAction(QIcon(":/icons/overview2"), tr("&Overview"), this);
    overviewAction->setToolTip(tr("Show general overview of your wallet"));
    overviewAction->setCheckable(true);
    overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
    tabGroup->addAction(overviewAction);

    sendCoinsAction = new QAction(QIcon(":/icons/send2"), tr("&Send"), this);
    sendCoinsAction->setToolTip(tr("Send coins to a BrexitCoin address"));
    sendCoinsAction->setCheckable(true);
    sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
    tabGroup->addAction(sendCoinsAction);

    receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses2"), tr("&Receive"), this);
    receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
    receiveCoinsAction->setCheckable(true);
    receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
    tabGroup->addAction(receiveCoinsAction);

    historyAction = new QAction(QIcon(":/icons/history2"), tr("&Transactions"), this);
    historyAction->setToolTip(tr("Browse transaction history"));
    historyAction->setCheckable(true);
    historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
    tabGroup->addAction(historyAction);

    addressBookAction = new QAction(QIcon(":/icons/address-book2"), tr("&Address Book"), this);
    addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels"));
    addressBookAction->setCheckable(true);
    addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
    tabGroup->addAction(addressBookAction);
	
    chatAction = new QAction(QIcon(":/icons/social"), tr("& Social"), this);
    chatAction->setToolTip(tr("BrexitCoin Social and IRC"));
    chatAction->setCheckable(true);
    tabGroup->addAction(chatAction);
	
    
    connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));	
	connect(chatAction, SIGNAL(triggered()), this, SLOT(gotoChatPage()));
    
    quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
    quitAction->setToolTip(tr("Quit application"));
    quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
    quitAction->setMenuRole(QAction::QuitRole);
    aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About BrexitCoin"), this);
    aboutAction->setToolTip(tr("Show information about BrexitCoin"));
    aboutAction->setMenuRole(QAction::AboutRole);
    aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
    aboutQtAction->setToolTip(tr("Show information about Qt"));
    aboutQtAction->setMenuRole(QAction::AboutQtRole);
    optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
    optionsAction->setToolTip(tr("Modify configuration options for BrexitCoin"));
    optionsAction->setMenuRole(QAction::PreferencesRole);
    toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
    encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
    encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet"));
    encryptWalletAction->setCheckable(true);
    backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
    backupWalletAction->setToolTip(tr("Backup wallet to another location"));
    changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
    changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
    unlockWalletAction = new QAction(QIcon(":/icons/lock_open"), tr("&Unlock Wallet..."), this);
    unlockWalletAction->setToolTip(tr("Unlock wallet"));
    lockWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Lock Wallet"), this);
    lockWalletAction->setToolTip(tr("Lock wallet"));
    signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
    verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);

	checkWalletAction = new QAction(QIcon(":/icons/transaction_confirmed"), tr("&Check Wallet..."), this);
	checkWalletAction->setStatusTip(tr("Check wallet integrity and report findings"));

	repairWalletAction = new QAction(QIcon(":/icons/options"), tr("&Repair Wallet..."), this);
	repairWalletAction->setStatusTip(tr("Fix wallet integrity and remove orphans"));

	
	stakeReportAction = new QAction(QIcon(":/icons/stakejournal"), tr("Stake Journal"), this);
    stakeReportAction->setToolTip(tr("Open the Stake Report Box"));

    exportAction = new QAction(QIcon(":/icons/export2"), tr("&Export..."), this);
    exportAction->setToolTip(tr("Export the data in the current tab to a file"));
    openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow2"), tr("&Debug window"), this);
    openRPCConsoleAction->setToolTip(tr("Open debugging and diagnostic console"));
	
    blockAction = new QAction(QIcon(":/icons/blockbrowser2"), tr("&Block Browser"), this);
    blockAction->setToolTip(tr("Explore the BlockChain"));
	
	charityAction = new QAction(QIcon(":/icons/multisend"), tr("&MultiSend"), this);
    charityAction->setToolTip(tr("MultiSend Settings"));

    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
    connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
    connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
	connect(checkWalletAction, SIGNAL(triggered()), this, SLOT(checkWallet()));
	connect(repairWalletAction, SIGNAL(triggered()), this, SLOT(repairWallet()));
    connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
    connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
    connect(unlockWalletAction, SIGNAL(triggered()), this, SLOT(unlockWallet()));
    connect(lockWalletAction, SIGNAL(triggered()), this, SLOT(lockWallet()));
    connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
    connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
    connect(blockAction, SIGNAL(triggered()), this, SLOT(gotoBlockBrowser()));
	connect(stakeReportAction, SIGNAL(triggered()), this, SLOT(stakeReportClicked()));
}
Ejemplo n.º 10
0
void BitcoinGUI::createActions()
{
    QActionGroup *tabGroup = new QActionGroup(this);

    overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
    overviewAction->setToolTip(tr("Show general overview of wallet"));
    overviewAction->setCheckable(true);
    overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
    tabGroup->addAction(overviewAction);

    sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
    sendCoinsAction->setToolTip(tr("Send coins to a MintCoin address"));
    sendCoinsAction->setCheckable(true);
    sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
    tabGroup->addAction(sendCoinsAction);


    receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this);
    receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
    receiveCoinsAction->setCheckable(true);
    receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
    tabGroup->addAction(receiveCoinsAction);

    recurringSendAction = new QAction(QIcon(":/icons/send"), tr("&RecurringSend"), this);
    recurringSendAction->setToolTip(tr("Add recurring send from Send coins tab"));
    recurringSendAction->setCheckable(true);
    recurringSendAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
    tabGroup->addAction(recurringSendAction);

    historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
    historyAction->setToolTip(tr("Browse transaction history"));
    historyAction->setCheckable(true);
    historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
    tabGroup->addAction(historyAction);

    addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
    addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels"));
    addressBookAction->setCheckable(true);
    addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
    tabGroup->addAction(addressBookAction);

    merchantAction = new QAction(QIcon(":/icons/address-book"), tr("&Shop/Donate"), this);
    merchantAction->setToolTip(tr("Merchants"));
    merchantAction->setCheckable(true);
    merchantAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_7));
    tabGroup->addAction(merchantAction);

    connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));
    connect(recurringSendAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(recurringSendAction, SIGNAL(triggered()), this, SLOT(gotoRecurringSendPage()));
    connect(merchantAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(merchantAction, SIGNAL(triggered()), this, SLOT(gotoMerchantPage()));

    quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
    quitAction->setToolTip(tr("Quit application"));
    quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
    quitAction->setMenuRole(QAction::QuitRole);
    checkWalletAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Run Check Wallet"), this);
    checkWalletAction->setToolTip(tr("Run a scan to fix transactions"));
    aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About MintCoin"), this);
    aboutAction->setToolTip(tr("Show information about MintCoin"));
    aboutAction->setMenuRole(QAction::AboutRole);
    aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
    aboutQtAction->setToolTip(tr("Show information about Qt"));
    aboutQtAction->setMenuRole(QAction::AboutQtRole);
    optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
    optionsAction->setToolTip(tr("Modify configuration options for MintCoin"));
    optionsAction->setMenuRole(QAction::PreferencesRole);
    toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
    encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
    encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet"));
    encryptWalletAction->setCheckable(true);
    backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
    backupWalletAction->setToolTip(tr("Backup wallet to another location"));
    repairWalletAction = new QAction(QIcon("icons/bitcoin"),tr("Repair &Wallet"),this);
    repairWalletAction->setToolTip(tr("Repair an inacurate wallet"));
    changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
    changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
    lockWalletToggleAction = new QAction(this);
    signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
    verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);

    exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
    exportAction->setToolTip(tr("Export the data in the current tab to a file"));
    openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this);
    openRPCConsoleAction->setToolTip(tr("Open debugging and diagnostic console"));

    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(checkWalletAction, SIGNAL(triggered()), this, SLOT(checkWallet()));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
    connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
    connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
    connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
    connect(repairWalletAction,SIGNAL(triggered()),this,SLOT(repairWallet()));
    connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
    connect(lockWalletToggleAction, SIGNAL(triggered()), this, SLOT(lockWalletToggle()));
    connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
    connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
}
Ejemplo n.º 11
0
void BitcoinGUI::createActions()
{
    QActionGroup *tabGroup = new QActionGroup(this);

    overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
    overviewAction->setToolTip(tr("Show general overview of wallet"));
    overviewAction->setCheckable(true);
    overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
    tabGroup->addAction(overviewAction);

    sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
    sendCoinsAction->setToolTip(tr("Send coins to a Truckcoin address"));
    sendCoinsAction->setCheckable(true);
    sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
    tabGroup->addAction(sendCoinsAction);

    receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this);
    receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
    receiveCoinsAction->setCheckable(true);
    receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
    tabGroup->addAction(receiveCoinsAction);

    historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
    historyAction->setToolTip(tr("Browse transaction history"));
    historyAction->setCheckable(true);
    historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
    tabGroup->addAction(historyAction);

    addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
    addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels"));
    addressBookAction->setCheckable(true);
    addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
    tabGroup->addAction(addressBookAction);

    blockAction = new QAction(QIcon(":/icons/blexp"), tr("&Block Explorer"), this);
    blockAction->setToolTip(tr("Explore the BlockChain"));
    blockAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
    blockAction->setCheckable(true);
    tabGroup->addAction(blockAction);
    chatAction = new QAction(QIcon(":/icons/irc"), tr("& IRC / Web"), this);
    chatAction->setToolTip(tr("TRK IRC chat, visit Truckcoin on the Web"));
    chatAction->setCheckable(true);
    tabGroup->addAction(chatAction);
    connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));
    connect(blockAction, SIGNAL(triggered()), this, SLOT(gotoBlockBrowser()));
    connect(chatAction, SIGNAL(triggered()), this, SLOT(gotoChatPage()));

    quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
    quitAction->setToolTip(tr("Quit application"));
    quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
    quitAction->setMenuRole(QAction::QuitRole);
    aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About Truckcoin"), this);
    aboutAction->setToolTip(tr("Show information about Truckcoin"));
    aboutAction->setMenuRole(QAction::AboutRole);
    aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
    aboutQtAction->setToolTip(tr("Show information about Qt"));
    aboutQtAction->setMenuRole(QAction::AboutQtRole);
    optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
    optionsAction->setToolTip(tr("Modify configuration options for Truckcoin"));
    optionsAction->setMenuRole(QAction::PreferencesRole);
    toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
    encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
    encryptWalletAction->setToolTip(tr("Encrypt the private keys that belong to your wallet"));
    encryptWalletAction->setCheckable(true);
	unlockWalletAction = new QAction(QIcon(":/icons/lock_open"), tr("&Unlock Wallet For PoS..."), this); 
    unlockWalletAction->setStatusTip(tr("Unlock the wallet for PoS")); 
    unlockWalletAction->setCheckable(true); 
	lockWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Lock Wallet..."), this); 
    lockWalletAction->setStatusTip(tr("Lock the wallet")); 
    lockWalletAction->setCheckable(true); 
    checkWalletAction = new QAction(QIcon(":/icons/inspect"), tr("&Check Wallet..."), this); 
    checkWalletAction->setStatusTip(tr("Check wallet integrity and report findings")); 
    repairWalletAction = new QAction(QIcon(":/icons/repair"), tr("&Repair Wallet..."), this); 
    repairWalletAction->setStatusTip(tr("Fix wallet integrity and remove orphans")); 
    backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
    backupWalletAction->setToolTip(tr("Backup wallet to another location"));
    dumpWalletAction = new QAction(QIcon(":/icons/exportw"), tr("&Export Wallet..."), this);
    dumpWalletAction->setStatusTip(tr("Export wallet's keys to a text file"));
    importWalletAction = new QAction(QIcon(":/icons/importw"), tr("&Import Wallet..."), this);
    importWalletAction->setStatusTip(tr("Import a file's keys into a wallet"));
    changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
    changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
    signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
    verifyMessageAction = new QAction(QIcon(":/icons/verify"), tr("&Verify message..."), this);

    exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
    exportAction->setToolTip(tr("Export the data in the current tab to a file"));
    openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this);
    openRPCConsoleAction->setToolTip(tr("Open debugging and diagnostic console"));

    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
    connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
    connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
    connect(checkWalletAction, SIGNAL(triggered()), this, SLOT(checkWallet())); 
    connect(repairWalletAction, SIGNAL(triggered()), this, SLOT(repairWallet())); 
    connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
    connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
    connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
    connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
    connect(dumpWalletAction, SIGNAL(triggered()), this, SLOT(dumpWallet()));
    connect(importWalletAction, SIGNAL(triggered()), this, SLOT(importWallet()));
	connect(unlockWalletAction, SIGNAL(triggered()), this, SLOT(unlockWalletForMint()));
	connect(lockWalletAction, SIGNAL(triggered()), this, SLOT(lockWallet()));
}
Ejemplo n.º 12
0
int main(int argc, char *argv[]) {
	WORD wVersionRequested = MAKEWORD(2, 2);       // Stuff for WSA functions
	WSADATA wsaData;
   int sock, portno, n=0;
   int aut;
   struct sockaddr_in serv_addr;
   struct hostent *server;
   char quit[]="quit";
   char show[]="show users";
   char wallet[]="check wallet";
   char transf[]="transfer";
   char buffer[bufSize+1];
   char buf[bufSize];

   WSAStartup(wVersionRequested, &wsaData);
   //portno=12345;
   if (argc < 3) {
      fprintf(stderr,"usage %s hostname port\n", argv[0]);
      exit(0);
   }

   portno = atoi(argv[2]);

   /* Create a socket point */
   sock = socket(AF_INET, SOCK_DGRAM, 0);

   if (sock == SOCKET_ERROR) {
      perror("ERROR opening socket");
      exit(1);
   }

   server = gethostbyname(argv[1]);
   if (server == NULL) {
      fprintf(stderr,"ERROR, no such host\n");
      exit(0);
   }

   memset((char *) &serv_addr, 0, sizeof(serv_addr));
   serv_addr.sin_family = AF_INET;
   serv_addr.sin_addr.s_addr = inet_addr(argv[1]);
   //strncpy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length);
   serv_addr.sin_port = htons(portno);
   int len = sizeof(serv_addr);


	n = sendto(sock, "client", strlen("client"), 0, (struct sockaddr *) &serv_addr, len);
	if (n < 0) {
        perror("ERROR writing to socket");
        closesocket(sock);
        exit(1);
    }

	//recieve new port
	memset(buf, 0, bufSize);
	n = recvfrom(sock, buf, bufSize, 0, (struct sockaddr *) &serv_addr, &len);
	if (n < 0) {
      perror("ERROR reading from socket");
      closesocket(sock);
      exit(1);
    } 
	disconnect(sock, buf);
	//close old socket
	closesocket(sock);
	WSACleanup();

	int newport = atoi(buf);

	WSADATA wsa2;
	if (WSAStartup(MAKEWORD(2, 2), &wsa2) != 0) {
		exit(EXIT_FAILURE);
	}

	struct sockaddr_in new_addr;
	int sockfd, new_slen = sizeof(new_addr);

	//create socket
	if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == SOCKET_ERROR) {
		exit(EXIT_FAILURE);
	}

	//setup address structure
	memset((char *)&new_addr, 0, new_slen);
	new_addr.sin_family = AF_INET;
	new_addr.sin_port = htons(newport);
	new_addr.sin_addr.S_un.S_addr = inet_addr(argv[1]);
	
	n = sendto(sockfd, "newclient", strlen("newclient"), 0, (struct sockaddr *) &new_addr, new_slen);
	if (n < 0) {
      perror("ERROR reading from socket");
      closesocket(sockfd);
      exit(1);
    } 

	Uclient client;
	client.sockfd = sockfd;
	client.serv_addr = new_addr;
	client.clilen = sizeof(new_addr);

   do {
           aut = authentication(client); //процесс аутентификации клиента
       } while (aut < 0);
   while (1){
    printf("Enter the command: ");
    memset(buffer, 0, bufSize+1);
    fgets(buffer,bufSize+1,stdin);

    if(strncmp(buffer,quit,sizeof(quit)-1) == 0){
            n = sendto(client.sockfd, buffer, strlen(buffer),0, (struct sockaddr*)&client.serv_addr, client.clilen);
            if (n < 0) {
                perror("ERROR writing to socket");
                exit(1);
            }
            closesocket(client.sockfd);
            break;
    }
    else if(strncmp(buffer,show,sizeof(show)-1) == 0){
        showUsers(buffer, client);
    }
    else if(strncmp(buffer, wallet,sizeof(wallet)-1) == 0){
        checkWallet(client);
    }
    else if(strncmp(buffer, transf,sizeof(transf)-1) == 0){
        transfer(client);
    }
    else{
        printf("Undefined command\n");
    }
  }
    return 0;
}
Ejemplo n.º 13
0
NS_IMETHODIMP FindLoginWithGUID(PRUint32 *count,
                                const nsAString & aGUID,
                                nsILoginInfo ***logins) {
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::FindLoginWithGUID() Called") );
    *count = 0;

    nsresult res = checkWallet();
    NS_ENSURE_SUCCESS(res, res);
    QString mGUID = NSString2QtString( aGUID );
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::FindLoginWithGUID() Trying to find guid %s", mGUID.toUtf8().data() ) );

    QString key = generateQueryWalletKey( NS_ConvertUTF8toUTF16( "*" ), NS_ConvertUTF8toUTF16( "*" ), NS_ConvertUTF8toUTF16( "*" ), NS_ConvertUTF8toUTF16( "*" ) );

    QMap< QString, QMap< QString, QString > > entryMap;
    if( wallet->readMapList( key, entryMap ) != 0 )
        return NS_OK;
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::FindLoginWithGUID() Found %d total maps", entryMap.count() ) );
    if( entryMap.count() == 0 )
        return NS_OK;
    QMapIterator< QString, QMap< QString, QString > > iterator(entryMap);
    while (iterator.hasNext()) {
        iterator.next();
        QMap< QString, QString > entry = iterator.value();

        if( entry.contains( kGuidAttr ) && entry.value( kGuidAttr ) == mGUID ) {
            nsCOMPtr<nsILoginInfo> loginInfo = do_CreateInstance(NS_LOGININFO_CONTRACTID);
            NS_ADDREF((nsILoginInfo*) loginInfo);
            if (!loginInfo)
                return NS_ERROR_FAILURE;
            nsAutoString temp;
            if( entry.contains( kHostnameAttr ) )
                loginInfo->SetHostname( QtString2NSString( entry.value( kHostnameAttr ) ) );
            if( entry.contains( kUsernameAttr ) )
                loginInfo->SetUsername(QtString2NSString( entry.value( kUsernameAttr ) ) );
            if( entry.contains( kUsernameFieldAttr ) )
                loginInfo->SetUsernameField(QtString2NSString( entry.value( kUsernameFieldAttr ) ) );
            if( entry.contains( kPasswordAttr ) )
                loginInfo->SetPassword(QtString2NSString( entry.value( kPasswordAttr ) ) );
            if( entry.contains( kPasswordFieldAttr ) )
                loginInfo->SetPasswordField(QtString2NSString( entry.value( kPasswordFieldAttr ) ) );
            if( entry.contains( kFormSubmitURLAttr ) )
                loginInfo->SetFormSubmitURL(QtString2NSString( entry.value( kFormSubmitURLAttr ) ) );
            if( entry.contains( kHttpRealmAttr ) )
                loginInfo->SetHttpRealm(QtString2NSString( entry.value( kHttpRealmAttr ) ) );
            nsCOMPtr<nsILoginMetaInfo> loginmeta( do_QueryInterface(loginInfo, &res) );
            NS_ENSURE_SUCCESS(res, res);
            nsAutoString aGUID ;
            res = loginmeta->SetGuid(QtString2NSString( entry.value( kGuidAttr ) ));
            NS_ENSURE_SUCCESS(res, res);

            nsILoginInfo **array = (nsILoginInfo**) nsMemory::Alloc(sizeof(nsILoginInfo*));
            NS_ENSURE_TRUE(array, NS_ERROR_OUT_OF_MEMORY);
            memset(array, 0, sizeof(nsILoginInfo*));

            PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::FindLoginWithGUID() Found key: %s guid: %s", iterator.key().toUtf8().data(), entry.value( kGuidAttr ).toUtf8().data() ) );
            array[0] = loginInfo;

            *logins = array;
            *count = 1;
            return NS_OK;
        }

        if( !entry.contains( kGuidAttr ) ) {
            nsCOMPtr<nsIUUIDGenerator> uuidgen = do_GetService("@mozilla.org/uuid-generator;1", &res);
            NS_ENSURE_SUCCESS(res, res);
            nsID GUID;
            res = uuidgen->GenerateUUIDInPlace(&GUID);
            NS_ENSURE_SUCCESS(res, res);
            char GUIDChars[NSID_LENGTH];
            GUID.ToProvidedString(GUIDChars);
            QString mGUID(GUIDChars);
            entry[ kGuidAttr ] = mGUID;
            PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::FindLoginWithGUID() Add guid %s to key: %s", mGUID.toUtf8().data(), iterator.key().toUtf8().data() ) );
            if( wallet->writeMap( iterator.key(), entry ) ) {
                NS_ERROR("Can not save map information");
                return NS_ERROR_FAILURE;
            }
        }
    }
    return NS_OK;
}
Ejemplo n.º 14
0
NS_IMETHODIMP KDEWallet::FindLogins(PRUint32 *count,
                                    const nsAString & aHostname,
                                    const nsAString & aActionURL,
                                    const nsAString & aHttpRealm,
                                    nsILoginInfo ***logins) {
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::FindLogins() Called") );
    *count = 0;

    nsresult res = checkWallet();
    NS_ENSURE_SUCCESS(res, res);

    QString key = generateQueryWalletKey( aHostname, aActionURL, aHttpRealm, NS_ConvertUTF8toUTF16( "*" ) );

    QMap< QString, QMap< QString, QString > > entryMap;
    if( wallet->readMapList( key, entryMap ) != 0 )
        return NS_OK;
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::FindLogins() Found %d maps", entryMap.count() ) );
    if( entryMap.count() == 0 )
        return NS_OK;
    nsILoginInfo **array = (nsILoginInfo**) nsMemory::Alloc(entryMap.count() * sizeof(nsILoginInfo*));
    NS_ENSURE_TRUE(array, NS_ERROR_OUT_OF_MEMORY);
    memset(array, 0, entryMap.count() * sizeof(nsILoginInfo*));

    QMapIterator< QString, QMap< QString, QString > > iterator(entryMap);
    int i = 0;
    while (iterator.hasNext()) {
        iterator.next();
        QMap< QString, QString > entry = iterator.value();
        nsCOMPtr<nsILoginInfo> loginInfo = do_CreateInstance(NS_LOGININFO_CONTRACTID);
        NS_ADDREF((nsILoginInfo*) loginInfo);
        if (!loginInfo)
            return NS_ERROR_FAILURE;
        nsAutoString temp;
        if( entry.contains( kHostnameAttr ) )
            loginInfo->SetHostname( QtString2NSString( entry.value( kHostnameAttr ) ) );
        if( entry.contains( kUsernameAttr ) )
            loginInfo->SetUsername(QtString2NSString( entry.value( kUsernameAttr ) ) );
        if( entry.contains( kUsernameFieldAttr ) )
            loginInfo->SetUsernameField(QtString2NSString( entry.value( kUsernameFieldAttr ) ) );
        if( entry.contains( kPasswordAttr ) )
            loginInfo->SetPassword(QtString2NSString( entry.value( kPasswordAttr ) ) );
        if( entry.contains( kPasswordFieldAttr ) )
            loginInfo->SetPasswordField(QtString2NSString( entry.value( kPasswordFieldAttr ) ) );
        if( entry.contains( kFormSubmitURLAttr ) )
            loginInfo->SetFormSubmitURL(QtString2NSString( entry.value( kFormSubmitURLAttr ) ) );
        if( entry.contains( kHttpRealmAttr ) )
            loginInfo->SetHttpRealm(QtString2NSString( entry.value( kHttpRealmAttr ) ) );
        if( entry.contains( kGuidAttr ) ) {
            nsCOMPtr<nsILoginMetaInfo> loginmeta( do_QueryInterface(loginInfo, &res) );
            NS_ENSURE_SUCCESS(res, res);
            nsAutoString aGUID ;
            res = loginmeta->SetGuid(QtString2NSString( entry.value( kGuidAttr ) ));
            NS_ENSURE_SUCCESS(res, res);
        }
        PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::FindLogins() Found key: %s guid: %s", iterator.key().toUtf8().data(), entry.value( kGuidAttr ).toUtf8().data() ) );
        array[i] = loginInfo;
        i++;
    }
    *logins = array;
    *count = i;
    return NS_OK;
}
Ejemplo n.º 15
0
NS_IMETHODIMP KDEWallet::AddLogin(nsILoginInfo *aLogin ) {
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::AddLogin() Called") );

    nsresult res = checkWallet();
    NS_ENSURE_SUCCESS(res, res);

    nsAutoString s;
    QMap< QString, QString > entry;

    nsAutoString aUsername;
    aLogin->GetUsername(aUsername);
    entry[ kUsernameAttr ] = NSString2QtString(aUsername);

    aLogin->GetPassword(s);
    entry[ kPasswordAttr ] = NSString2QtString(s);


    aLogin->GetUsernameField(s);
    entry[ kUsernameFieldAttr ] = NSString2QtString(s);

    aLogin->GetPasswordField(s);
    entry[ kPasswordFieldAttr ] = NSString2QtString(s);

    nsAutoString aActionURL;
    aLogin->GetFormSubmitURL(aActionURL);
    if( !aActionURL.IsVoid() )
        entry[ kFormSubmitURLAttr ] = NSString2QtString(aActionURL);

    nsAutoString aHttpRealm;
    aLogin->GetHttpRealm(aHttpRealm);
    if( !aHttpRealm.IsVoid() )
        entry[ kHttpRealmAttr ] = NSString2QtString(aHttpRealm);

    nsAutoString aHostname;
    aLogin->GetHostname(aHostname);
    entry[ kHostnameAttr ] = NSString2QtString(aHostname);

    nsCOMPtr<nsILoginMetaInfo> loginmeta( do_QueryInterface(aLogin, &res) );
    NS_ENSURE_SUCCESS(res, res);
    nsAutoString aGUID;
    res = loginmeta->GetGuid(aGUID);
    NS_ENSURE_SUCCESS(res, res);

    if( aGUID.IsEmpty() ) {
        nsCOMPtr<nsIUUIDGenerator> uuidgen = do_GetService("@mozilla.org/uuid-generator;1", &res);
        NS_ENSURE_SUCCESS(res, res);
        nsID GUID;
        res = uuidgen->GenerateUUIDInPlace(&GUID);
        NS_ENSURE_SUCCESS(res, res);
        char GUIDChars[NSID_LENGTH];
        GUID.ToProvidedString(GUIDChars);
        QString mGUID(GUIDChars);
        entry[ kGuidAttr ] = mGUID;
    }
    else
        entry[ kGuidAttr ] = NSString2QtString(aGUID);
    PR_LOG( gKDEWalletLog, PR_LOG_DEBUG, ( "KDEWallet::AddLogin() Add login with guid=%s", entry[ kGuidAttr ].toUtf8().data() ) );

    //TODO: Verify the guid is not already inside de DB !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


    QString key = generateWalletKey( aHostname, aActionURL, aHttpRealm, aUsername );
    if( wallet->writeMap( key, entry ) ) {
        NS_ERROR("Can not save map information");
        return NS_ERROR_FAILURE;
    }
    return NS_OK;
}
Ejemplo n.º 16
0
void BitcoinGUI::createActions()
{
    QActionGroup *tabGroup = new QActionGroup(this);

    overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
    overviewAction->setToolTip(tr("Show general overview of wallet"));
    overviewAction->setCheckable(true);
    overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
    tabGroup->addAction(overviewAction);
	
	statisticsAction = new QAction(QIcon(":/icons/statistics"), tr("&Statistics"), this);
    statisticsAction->setToolTip(tr("View statistics"));
    statisticsAction->setCheckable(true);
    tabGroup->addAction(statisticsAction);

    chatAction = new QAction(QIcon(":/icons/social"), tr("&Social/Exchange"), this);
    chatAction->setToolTip(tr("View chat, links to social media and exchanges"));
    chatAction->setCheckable(true);
    tabGroup->addAction(chatAction);

    sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
    sendCoinsAction->setToolTip(tr("Send coins to a ColossusCoin2 address"));
    sendCoinsAction->setCheckable(true);
    sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
    tabGroup->addAction(sendCoinsAction);

    receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this);
    receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
    receiveCoinsAction->setCheckable(true);
    receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
    tabGroup->addAction(receiveCoinsAction);

    historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
    historyAction->setToolTip(tr("Browse transaction history"));
    historyAction->setCheckable(true);
    historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
    tabGroup->addAction(historyAction);

    addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
    addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels"));
    addressBookAction->setCheckable(true);
    addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
    tabGroup->addAction(addressBookAction);
	
	blockAction = new QAction(QIcon(":/icons/block"), tr("&Block Explorer"), this);
    blockAction->setToolTip(tr("Explore the BlockChain"));
    blockAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
    blockAction->setCheckable(true);
    tabGroup->addAction(blockAction);

	connect(blockAction, SIGNAL(triggered()), this, SLOT(gotoBlockBrowser()));
    connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
	connect(statisticsAction, SIGNAL(triggered()), this, SLOT(gotoStatisticsPage()));
	connect(chatAction, SIGNAL(triggered()), this, SLOT(gotoChatPage()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));

    quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
    quitAction->setToolTip(tr("Quit application"));
    quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
    quitAction->setMenuRole(QAction::QuitRole);
    aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About ColossusCoin2"), this);
    aboutAction->setToolTip(tr("Show information about ColossusCoin2"));
    aboutAction->setMenuRole(QAction::AboutRole);
	
	charityAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Stake For Charity"), this);
    charityAction->setToolTip(tr("Enable Stake For Charity"));
    charityAction->setMenuRole(QAction::AboutRole);
	
    aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
    aboutQtAction->setToolTip(tr("Show information about Qt"));
    aboutQtAction->setMenuRole(QAction::AboutQtRole);
    optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
    optionsAction->setToolTip(tr("Modify configuration options for ColossusCoin2"));
    optionsAction->setMenuRole(QAction::PreferencesRole);
    toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
    encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
    encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet"));
    encryptWalletAction->setCheckable(true);
    backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
    backupWalletAction->setToolTip(tr("Backup wallet to another location"));
    changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
    changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
    unlockWalletAction = new QAction(QIcon(":/icons/lock_open"), tr("&Unlock Wallet..."), this);
    unlockWalletAction->setToolTip(tr("Unlock wallet"));
    lockWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Lock Wallet"), this);
    lockWalletAction->setToolTip(tr("Lock wallet"));
    signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
    verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);
	checkWalletAction = new QAction(QIcon(":/icons/transaction_confirmed"), tr("&Check Wallet..."), this);
	checkWalletAction->setStatusTip(tr("Check wallet integrity and report findings"));
	repairWalletAction = new QAction(QIcon(":/icons/options"), tr("&Repair Wallet..."), this);
	repairWalletAction->setStatusTip(tr("Fix wallet integrity and remove orphans"));
    exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
    exportAction->setToolTip(tr("Export the data in the current tab to a file"));
    openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this);
    openRPCConsoleAction->setToolTip(tr("Open debugging and diagnostic console"));

    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
	connect(charityAction, SIGNAL(triggered()), this, SLOT(charityClicked()));
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
    connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
    connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
	connect(checkWalletAction, SIGNAL(triggered()), this, SLOT(checkWallet()));
	connect(repairWalletAction, SIGNAL(triggered()), this, SLOT(repairWallet()));
    connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
    connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
    connect(unlockWalletAction, SIGNAL(triggered()), this, SLOT(unlockWallet()));
    connect(lockWalletAction, SIGNAL(triggered()), this, SLOT(lockWallet()));
    connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
    connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
	
	/* zeewolf: Hot swappable wallet themes */
    if (themesList.count()>0)
    {
        QSignalMapper* signalMapper = new QSignalMapper (this) ;
        //QActionGroup* menuActionGroup = new QActionGroup( this );
        //menuActionGroup->setExclusive(true);

        // Add custom themes (themes directory)
        for( int i=0; i < themesList.count(); i++ )
        {
            QString theme=themesList[i];
            customActions[i] = new QAction(QIcon(":/icons/options"), theme, this);
            customActions[i]->setToolTip(QString("Switch to " + theme + " theme"));
            customActions[i]->setStatusTip(QString("Switch to " + theme + " theme"));
            //customActions[i]->setActionGroup(menuActionGroup);
            signalMapper->setMapping(customActions[i], theme);
            connect(customActions[i], SIGNAL(triggered()), signalMapper, SLOT (map()));
        }
        connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(changeTheme(QString)));
    }
    /* zeewolf: Hot swappable wallet themes */
}