当前位置: 首页>>代码示例>>C++>>正文


C++ Account类代码示例

本文整理汇总了C++中Account的典型用法代码示例。如果您正苦于以下问题:C++ Account类的具体用法?C++ Account怎么用?C++ Account使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Account类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SeafileApiRequest

/**
 * GetUnseenSeahubNotificationsRequest
 */
GetUnseenSeahubNotificationsRequest::GetUnseenSeahubNotificationsRequest(const Account& account)
    : SeafileApiRequest (account.getAbsoluteUrl(kUnseenMessagesUrl),
                         SeafileApiRequest::METHOD_GET, account.token)
{
}
开发者ID:SmartCloud2025,项目名称:seafile-client,代码行数:8,代码来源:requests.cpp

示例2: testSignerLists

   // Test the "signer_lists" argument in account_info.
   void testSignerLists()
    {
        using namespace jtx;
        Env env(*this, with_features(featureMultiSign));
        Account const alice {"alice"};
        env.fund(XRP(1000), alice);

        auto const withoutSigners = std::string ("{ ") +
            "\"account\": \"" + alice.human() + "\"}";

        auto const withSigners = std::string ("{ ") +
            "\"account\": \"" + alice.human() + "\", " +
            "\"signer_lists\": true }";

        // Alice has no SignerList yet.
        {
            // account_info without the "signer_lists" argument.
            auto const info = env.rpc ("json", "account_info", withoutSigners);
            BEAST_EXPECT(info.isMember(jss::result) &&
                info[jss::result].isMember(jss::account_data));
            BEAST_EXPECT(! info[jss::result][jss::account_data].
                isMember (jss::signer_lists));
        }
        {
            // account_info with the "signer_lists" argument.
            auto const info = env.rpc ("json", "account_info", withSigners);
            BEAST_EXPECT(info.isMember(jss::result) &&
                info[jss::result].isMember(jss::account_data));
            auto const& data = info[jss::result][jss::account_data];
            BEAST_EXPECT(data.isMember (jss::signer_lists));
            auto const& signerLists = data[jss::signer_lists];
            BEAST_EXPECT(signerLists.isArray());
            BEAST_EXPECT(signerLists.size() == 0);
        }

        // Give alice a SignerList.
        Account const bogie {"bogie"};

        Json::Value const smallSigners = signers(alice, 2, { { bogie, 3 } });
        env(smallSigners);
        {
            // account_info without the "signer_lists" argument.
            auto const info = env.rpc ("json", "account_info", withoutSigners);
            BEAST_EXPECT(info.isMember(jss::result) &&
                info[jss::result].isMember(jss::account_data));
            BEAST_EXPECT(! info[jss::result][jss::account_data].
                isMember (jss::signer_lists));
        }
        {
            // account_info with the "signer_lists" argument.
            auto const info = env.rpc ("json", "account_info", withSigners);
            BEAST_EXPECT(info.isMember(jss::result) &&
                info[jss::result].isMember(jss::account_data));
            auto const& data = info[jss::result][jss::account_data];
            BEAST_EXPECT(data.isMember (jss::signer_lists));
            auto const& signerLists = data[jss::signer_lists];
            BEAST_EXPECT(signerLists.isArray());
            BEAST_EXPECT(signerLists.size() == 1);
            auto const& signers = signerLists[0u];
            BEAST_EXPECT(signers.isObject());
            BEAST_EXPECT(signers[sfSignerQuorum.jsonName] == 2);
            auto const& signerEntries = signers[sfSignerEntries.jsonName];
            BEAST_EXPECT(signerEntries.size() == 1);
            auto const& entry0 = signerEntries[0u][sfSignerEntry.jsonName];
            BEAST_EXPECT(entry0[sfSignerWeight.jsonName] == 3);
        }

        // Give alice a big signer list
        Account const demon {"demon"};
        Account const ghost {"ghost"};
        Account const haunt {"haunt"};
        Account const jinni {"jinni"};
        Account const phase {"phase"};
        Account const shade {"shade"};
        Account const spook {"spook"};

        Json::Value const bigSigners = signers(alice, 4, {
            {bogie, 1}, {demon, 1}, {ghost, 1}, {haunt, 1},
            {jinni, 1}, {phase, 1}, {shade, 1}, {spook, 1}, });
        env(bigSigners);
        {
            // account_info with the "signer_lists" argument.
            auto const info = env.rpc ("json", "account_info", withSigners);
            BEAST_EXPECT(info.isMember(jss::result) &&
                info[jss::result].isMember(jss::account_data));
            auto const& data = info[jss::result][jss::account_data];
            BEAST_EXPECT(data.isMember (jss::signer_lists));
            auto const& signerLists = data[jss::signer_lists];
            BEAST_EXPECT(signerLists.isArray());
            BEAST_EXPECT(signerLists.size() == 1);
            auto const& signers = signerLists[0u];
            BEAST_EXPECT(signers.isObject());
            BEAST_EXPECT(signers[sfSignerQuorum.jsonName] == 4);
            auto const& signerEntries = signers[sfSignerEntries.jsonName];
            BEAST_EXPECT(signerEntries.size() == 8);
            for (unsigned i = 0u; i < 8; ++i)
            {
                auto const& entry = signerEntries[i][sfSignerEntry.jsonName];
                BEAST_EXPECT(entry.size() == 2);
//.........这里部分代码省略.........
开发者ID:onedot618,项目名称:rippled,代码行数:101,代码来源:AccountInfo_test.cpp

示例3: info

//----------------------------------------------------------------------
int SipPhone::registerUser(const Account &acc)
{
    QString user = acc.getUserName();
    QString password = acc.getPassword();
    QString domain = acc.getHost();
    if (pjsua_acc_is_valid(acc_id_))
    {
        LogInfo info(LogInfo::STATUS_WARNING, "pjsip", 0, "Account already exists");
        signalLogData(info);
        return -1;
    }

    /* Register to SIP server by creating SIP account. */
    pjsua_acc_config cfg;

    pjsua_acc_config_default(&cfg);

    QString id = "sip:";
    id.append(user);
    id.append("@");
    id.append(domain);

    QString reg_uri = "sip:";
    reg_uri.append(domain);

    char ch_id[150];
    char ch_reg_uri[100];
    char ch_user[100];
    char ch_password[100];

    if (id.size() > 149 ||
        reg_uri.size() > 99 ||
        user.size() > 99 ||
        password.size() > 99)
    {
        LogInfo info(LogInfo::STATUS_ERROR, "pjsip", 0, "Error adding account, data too long");
        signalLogData(info);
        return -1;
    }

    strcpy(ch_id, id.toLocal8Bit().data());
    ch_id[id.size()] = 0;

    strcpy(ch_reg_uri, reg_uri.toLocal8Bit().data());
    ch_reg_uri[reg_uri.size()] = 0;

    strcpy(ch_user, user.toLocal8Bit().data());
    ch_user[user.size()] = 0;
    strcpy(ch_password, password.toLocal8Bit().data());
    ch_password[password.size()] = 0;

    cfg.id = pj_str(ch_id);
    cfg.reg_uri = pj_str(ch_reg_uri);
    cfg.cred_count = 1;
    cfg.cred_info[0].realm = pj_str((char*)"*");
    cfg.cred_info[0].scheme = pj_str((char*)"digest");
    cfg.cred_info[0].username = pj_str(ch_user);
    cfg.cred_info[0].data_type = 0;
    cfg.cred_info[0].data = pj_str(ch_password);

    pj_status_t status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id_);

    if (status != PJ_SUCCESS)
    {
        LogInfo info(LogInfo::STATUS_ERROR, "pjsip", status, "Error adding account");
        signalLogData(info);
        return -1;
    }
    LogInfo info(LogInfo::STATUS_MESSAGE, "pjsip", 0, "Registered user with account-id "
                 + QString::number(acc_id_));
    signalLogData(info);

    return acc_id_;
}
开发者ID:BillTheBest,项目名称:GreenJ,代码行数:75,代码来源:sip_phone.cpp

示例4: removeAccount

void Prefs::removeAccount(int accNumber)
{
  Account* acc = accounts.at(accNumber);
  acc->remove();
  accounts.removeAt(accNumber);
}
开发者ID:PKEv,项目名称:YakaPhone,代码行数:6,代码来源:prefs.cpp

示例5: makeBody

	virtual void makeBody(GDynamicPageSession* pSession, ostream& response)
	{
		if(pSession->paramsLen() <= 0)
		{
			// Show the upload form
			response << "You can submit a file here. It must be less than 25 MB.<br>\n";
			response << "<form method='POST' enctype='multipart/form-data' action='/upload'>\n";
			response << "	Competition: <select name=competition>\n";
			response << "		<option value=\"1\">1) Classification predictive accuracy</option>\n";
			response << "		<option value=\"2\">2) Area under ROC curve with binary classification sets</option>\n";
			response << "		<option value=\"3\">3) Classification of hand-written numbers</option>\n";
			response << "		<option value=\"4\">4) Precision-recall with multi-class data</option>\n";
			response << "		<option value=\"5\">5) Efficient classification with large datasets</option>\n";
			response << "		<option value=\"6\">6) Precision-recall with multi-class data</option>\n";
			response << "		<option value=\"7\">7) Incremental/stream learning tests</option>\n";
			response << "		<option value=\"8\">8) Active learning tests</option>\n";
			response << "		<option value=\"9\">9) Robustness to irrelevant features tests</option>\n";
			response << "	</select><br>\n";
			response << "	File to upload: <input type=file name=upfile><br>\n";
			response << "	<input type=submit value=Submit> (Please press submit only once!)\n";
			response << "</form><br><br>\n";
		}
		else
		{
			// Make a folder for this upload
			Account* pAccount = getAccount(pSession);
			string s = m_basePath;
			s += "uploads/";
			s += pAccount->username();
			s += "/";
			string timestamp;
			GTime::appendTimeStampValue(&timestamp, true/*use GMT*/);
			s += timestamp;
			s += "/";
			GFile::makeDir(s.c_str());

			// Extract and save the uploaded data
			string meta = "username=";
			meta += pAccount->username();
			meta += "\ntimestamp=";
			meta += timestamp;
			meta += "\n";
			int nameStart, nameLen, valueStart, valueLen, filenameStart, filenameLen;
			GHttpMultipartParser parser(pSession->params(), pSession->paramsLen());
			while(parser.next(&nameStart, &nameLen, &valueStart, &valueLen, &filenameStart, &filenameLen))
			{
				if(nameStart >= 0)
					meta.append(pSession->params() + nameStart, nameLen);
				else
					meta += "?";
				meta += "=";
				if(filenameStart >= 0)
				{
					meta.append(pSession->params() + filenameStart, filenameLen);
					string s2 = s;
					s2.append(pSession->params() + filenameStart, filenameLen);
					GFile::saveFile(pSession->params() + valueStart, valueLen, s2.c_str());
				}
				else
					meta.append(pSession->params() + valueStart, valueLen);
				meta += "\n";
			}
			s += "meta.txt";
			GFile::saveFile(meta.c_str(), meta.length(), s.c_str());

			// Send an email to notify the administrator
//			GSmtp::sendEmail("[email protected]", "[email protected]", "The following file has been uploaded", meta.c_str(), "smtp.domain.com");

			// Inform the user that the submission was received
			response << "The following submission was received:<br><pre>\n";
			response << meta.c_str();
			response << "</pre><br><br>\n\n";
			response << "Have a nice day!\n";
		}
	}
开发者ID:darthsuogles,项目名称:GestureUI,代码行数:75,代码来源:main.cpp

示例6: ConfigurationWindow

MainConfigurationWindow::MainConfigurationWindow() :
    ConfigurationWindow("MainConfiguration", tr("Kadu configuration"), "General", instanceDataManager()), lookChatAdvanced(0)
{
    setWindowRole("kadu-configuration");

    widget()->appendUiFile(dataPath("kadu/configuration/dialog.ui"));

#ifndef DEBUG_ENABLED
    ((QWidget *)(widget()->widgetById("debug")->parent()))->hide();
#endif

#ifndef Q_OS_WIN
    ((QWidget *)(widget()->widgetById("startup")))->hide();
#endif

#ifndef Q_WS_X11
    ((QWidget *)(widget()->widgetById("windowActivationMethodGroup")))->hide();
    ((QWidget *)(widget()->widgetById("notify/fullscreenSilentMode")))->hide();
#endif

    onStartupSetLastDescription = static_cast<QCheckBox *>(widget()->widgetById("onStartupSetLastDescription"));
    QLineEdit *disconnectDescription = static_cast<QLineEdit *>(widget()->widgetById("disconnectDescription"));
    QLineEdit *onStartupSetDescription = static_cast<QLineEdit *>(widget()->widgetById("onStartupSetDescription"));

    Account account = AccountManager::instance()->defaultAccount();
    if (!account.isNull() && account.protocolHandler())
    {
        disconnectDescription->setMaxLength(account.data()->maxDescriptionLength());
        onStartupSetDescription->setMaxLength(account.data()->maxDescriptionLength());
    }
//	connect(widget()->widgetById("advancedMode"), SIGNAL(toggled(bool)), widget()->widgetById("contactsWithIcons"), SLOT(setEnabled(bool)));
    connect(widget()->widgetById("showAvatars"), SIGNAL(toggled(bool)), widget()->widgetById("avatarBorder"), SLOT(setEnabled(bool)));
    connect(widget()->widgetById("showAvatars"), SIGNAL(toggled(bool)), widget()->widgetById("avatarGreyOut"), SLOT(setEnabled(bool)));
    connect(widget()->widgetById("disconnectWithCurrentDescription"), SIGNAL(toggled(bool)), disconnectDescription, SLOT(setDisabled(bool)));
    connect(onStartupSetLastDescription, SIGNAL(toggled(bool)), onStartupSetDescription, SLOT(setDisabled(bool)));
    connect(widget()->widgetById("foldLink"), SIGNAL(toggled(bool)), widget()->widgetById("linkFoldTreshold"), SLOT(setEnabled(bool)));
    connect(widget()->widgetById("chatPrune"), SIGNAL(toggled(bool)), widget()->widgetById("chatPruneLen"), SLOT(setEnabled(bool)));
    connect(widget()->widgetById("chatCloseTimer"), SIGNAL(toggled(bool)), widget()->widgetById("chatCloseTimerPeriod"), SLOT(setEnabled(bool)));
    connect(widget()->widgetById("startupStatus"), SIGNAL(activated(int)), this, SLOT(onChangeStartupStatus(int)));
    connect(widget()->widgetById("infoPanelBgFilled"), SIGNAL(toggled(bool)), widget()->widgetById("infoPanelBgColor"), SLOT(setEnabled(bool)));
    connect(widget()->widgetById("showDescription"), SIGNAL(toggled(bool)), widget()->widgetById("multilineDescription"), SLOT(setEnabled(bool)));
//	connect(widget()->widgetById("useDefaultServers"), SIGNAL(toggled(bool)), widget()->widgetById("serverList"), SLOT(setDisabled(bool)));
    connect(widget()->widgetById("openChatOnMessage"), SIGNAL(toggled(bool)), widget()->widgetById("openChatOnMessageWhenOnline"), SLOT(setEnabled(bool)));

    connect(widget()->widgetById("displayGroupTabs"), SIGNAL(toggled(bool)), widget()->widgetById("showGroupAll"), SLOT(setEnabled(bool)));

    emoticonsStyleComboBox = static_cast<ConfigComboBox *>(widget()->widgetById("emoticonsStyle"));
    emoticonsThemeComboBox = static_cast<ConfigComboBox *>(widget()->widgetById("emoticonsTheme"));
    emoticonsScalingComboBox = static_cast<ConfigComboBox *>(widget()->widgetById("emoticonsScaling"));
    connect(emoticonsThemeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onChangeEmoticonsTheme(int)));
    connect(widget()->widgetById("emoticonsPaths"), SIGNAL(changed()), this, SLOT(setEmoticonThemes()));

    QWidget *showInformationPanel = widget()->widgetById("showInformationPanel");
    connect(showInformationPanel, SIGNAL(toggled(bool)), widget()->widgetById("showVerticalScrollbar"), SLOT(setEnabled(bool)));
    connect(showInformationPanel, SIGNAL(toggled(bool)), widget()->widgetById("showEmoticonsInPanel"), SLOT(setEnabled(bool)));

    ConfigCheckBox *useDefaultBrowserCheckbox = static_cast<ConfigCheckBox *>(widget()->widgetById("useDefaultBrowser"));
    ConfigLineEdit *browserCommandLineEdit = static_cast<ConfigLineEdit *>(widget()->widgetById("browserPath"));
    connect(useDefaultBrowserCheckbox, SIGNAL(toggled(bool)), browserCommandLineEdit, SLOT(setDisabled(bool)));

    ConfigCheckBox *useDefaultEMailCheckbox = static_cast<ConfigCheckBox *>(widget()->widgetById("useDefaultEMail"));
    ConfigLineEdit *mailCommandLineEdit = static_cast<ConfigLineEdit *>(widget()->widgetById("mailPath"));
    connect(useDefaultEMailCheckbox, SIGNAL(toggled(bool)), mailCommandLineEdit, SLOT(setDisabled(bool)));

    connect(widget()->widgetById("lookChatAdvanced"), SIGNAL(clicked()), this, SLOT(showLookChatAdvanced()));

    Preview *infoPanelSyntaxPreview = static_cast<Preview *>(widget()->widgetById("infoPanelSyntaxPreview"));
    infoPanelSyntaxPreview->setResetBackgroundColor(config_file.readEntry("Look", "InfoPanelBgColor"));
    connect(infoPanelSyntaxPreview, SIGNAL(needFixup(QString &)), Core::instance()->kaduWindow()->infoPanel(), SLOT(styleFixup(QString &)));
    connect(widget()->widgetById("infoPanelSyntax"), SIGNAL(syntaxChanged(const QString &)), infoPanelSyntaxPreview, SLOT(syntaxChanged(const QString &)));
    connect(widget()->widgetById("infoPanelSyntax"), SIGNAL(onSyntaxEditorWindowCreated(SyntaxEditorWindow *)),
            this, SLOT(onInfoPanelSyntaxEditorWindowCreated(SyntaxEditorWindow *)));

    connect(widget()->widgetById("iconPaths"), SIGNAL(changed()), this, SLOT(setIconThemes()));

    connect(widget()->widgetById("ignoreMessagesFromAnonymous"), SIGNAL(toggled(bool)), widget()->widgetById("ignoreMessagesFromAnonymousInConferences"), SLOT(setEnabled(bool)));

    QWidget *useUserboxBackground = widget()->widgetById("useUserboxBackground");
    connect(useUserboxBackground, SIGNAL(toggled(bool)), widget()->widgetById("userboxBackground"), SLOT(setEnabled(bool)));
    connect(useUserboxBackground, SIGNAL(toggled(bool)), widget()->widgetById("userboxBackgroundDisplayStyle"), SLOT(setEnabled(bool)));

    widget()->widgetById("parseStatus")->setToolTip(qApp->translate("@default", SyntaxText));
    (static_cast<ConfigSyntaxEditor *>(widget()->widgetById("infoPanelSyntax")))->setSyntaxHint(qApp->translate("@default", SyntaxText));

    userboxTransparency = static_cast<QCheckBox *>(widget()->widgetById("userboxTransparency"));
    userboxAlpha = static_cast<QSlider *>(widget()->widgetById("userboxAlpha"));
    connect(userboxTransparency, SIGNAL(toggled(bool)), widget()->widgetById("userboxAlpha"), SLOT(setEnabled(bool)));

    buddyColors = new BuddyListBackgroundColorsWidget(this);

    triggerCompositingStateChanged();
}
开发者ID:partition,项目名称:kadu,代码行数:92,代码来源:main-configuration-window.cpp

示例7: test_getType

void SystemAccounttest::test_getType()
{
    const char * type = m_account->getType();

    ASSERT_EQUAL(std::string("sys"), type);
}
开发者ID:LawrenceWeng,项目名称:cyphesis,代码行数:6,代码来源:SystemAccounttest.cpp

示例8: initStyleOption

void
AccountFactoryWrapperDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    QStyleOptionViewItemV4 opt = option;
    initStyleOption( &opt, index );

    const int center = opt.rect.height() / 2 + opt.rect.top();
    const int topIcon = center - ICON_SIZE/2;

    // draw the background
    const QWidget* w = opt.widget;
    QStyle* style = w ? w->style() : QApplication::style();
    style->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, w );

    Account* acc = qobject_cast< Account* >( index.data( AccountFactoryWrapper::AccountRole ).value< QObject* >() );
    Q_ASSERT( acc );

    // Checkbox on left edge, then text
    const QRect checkRect( PADDING/4, PADDING/4 + opt.rect.top(), opt.rect.height() - PADDING/4, opt.rect.height() - PADDING/4 );
    m_cachedCheckRects[ index ] = checkRect;
    QStyleOptionViewItemV4 opt2 = opt;
    opt2.rect = checkRect;
    opt.checkState == Qt::Checked ? opt2.state |= QStyle::State_On : opt2.state |= QStyle::State_Off;
    style->drawPrimitive( QStyle::PE_IndicatorViewItemCheck, &opt2, painter, w );

    // name on left
    painter->drawText( opt.rect.adjusted( checkRect.right() + PADDING, PADDING, -PADDING, -PADDING ), Qt::AlignLeft | Qt::AlignVCenter, acc->accountFriendlyName() );

    // remove, config, status on right
    const QRect pmRect( opt.rect.right() - PADDING - ICON_SIZE, topIcon, ICON_SIZE, ICON_SIZE );
    painter->drawPixmap( pmRect, TomahawkUtils::defaultPixmap( TomahawkUtils::ListRemove, TomahawkUtils::Original, pmRect.size() ) );
    m_cachedButtonRects[ index ] = pmRect;

    const QRect confRect( pmRect.left() - PADDING - CONFIG_WRENCH_SIZE, center - CONFIG_WRENCH_SIZE/2, CONFIG_WRENCH_SIZE, CONFIG_WRENCH_SIZE );

    QStyleOptionToolButton topt;
    topt.rect = confRect;
    topt.pos = confRect.topLeft();
    topt.font = opt.font;
    topt.icon = ImageRegistry::instance()->pixmap( RESPATH "images/configure.svg", QSize( CONFIG_WRENCH_SIZE - 8, CONFIG_WRENCH_SIZE - 8 ) );
    topt.iconSize = QSize( CONFIG_WRENCH_SIZE - 8, CONFIG_WRENCH_SIZE - 8 );
    topt.subControls = QStyle::SC_ToolButton;
    topt.activeSubControls = QStyle::SC_None;
    topt.features = QStyleOptionToolButton::None;
    bool pressed = ( m_configPressed == opt.index );
    topt.state = pressed ? QStyle::State_On : QStyle::State_Raised;
    if( opt.state & QStyle::State_MouseOver || pressed )
        topt.state |= QStyle::State_HasFocus;
    style->drawComplexControl( QStyle::CC_ToolButton, &topt, painter, w );
    m_cachedConfigRects[ index ] = confRect;

    QPixmap p;
    QString statusText;
    Account::ConnectionState state = acc->connectionState();
    const QRect connectIconRect( confRect.left() - PADDING - ICON_SIZE, topIcon, ICON_SIZE, ICON_SIZE );

    if ( state == Account::Connected )
    {
        p = TomahawkUtils::defaultPixmap( TomahawkUtils::SipPluginOnline, TomahawkUtils::Original, connectIconRect.size() );
        statusText = tr( "Online" );
    }
    else if ( state == Account::Connecting )
    {
        p = TomahawkUtils::defaultPixmap( TomahawkUtils::SipPluginOffline, TomahawkUtils::Original, connectIconRect.size() );
        statusText = tr( "Connecting..." );
    }
    else
    {
        p = TomahawkUtils::defaultPixmap( TomahawkUtils::SipPluginOffline, TomahawkUtils::Original, connectIconRect.size() );
        statusText = tr( "Offline" );
    }

    painter->drawPixmap( connectIconRect, p );

    int width = painter->fontMetrics().width( statusText );
    painter->drawText( QRect( connectIconRect.left() - PADDING - width, center - painter->fontMetrics().height()/2, width, painter->fontMetrics().height() ), statusText );

}
开发者ID:AidedPolecat6,项目名称:tomahawk,代码行数:78,代码来源:AccountFactoryWrapperDelegate.cpp

示例9: from

void HistoryWindow::on_dateTreeWidget_currentItemChanged(QTreeWidgetItem *dayItem, QTreeWidgetItem *)
{
	QTreeWidgetItem *monthItem = dayItem ? dayItem->parent() : nullptr;
	if (!dayItem || !monthItem)
		return;

	if (dayItem->data(0, Qt::UserRole).type() != QVariant::Date)
		return;
	if (monthItem->data(0, Qt::UserRole).type() != QVariant::Date)
		return;

	auto contactIndex = ui.fromComboBox->currentIndex();
	auto contactInfo = ui.fromComboBox->itemData(contactIndex).value<History::ContactInfo>();
	auto date = dayItem->data(0, Qt::UserRole).toDate();
	QDateTime from(date, QTime(0, 0));
	QDateTime to(date, QTime(23, 59, 59, 999));
	int count = std::numeric_limits<int>::max();

	history()->read(contactInfo, from, to, count).connect(this, [this, contactInfo, date] (const MessageList &messages) {
		int contactIndex = ui.fromComboBox->currentIndex();
		auto currentContactInfo = ui.fromComboBox->itemData(contactIndex).value<History::ContactInfo>();
		if (!(currentContactInfo == contactInfo))
			return;

		QTextDocument *doc = ui.historyLog->document();
		doc->setParent(0);
		ui.historyLog->setDocument(0);
		doc->clear();
		QTextCursor cursor = QTextCursor(doc);
		QTextCharFormat defaultFont = cursor.charFormat();
		QTextCharFormat serviceFont = cursor.charFormat();
		serviceFont.setForeground(Qt::darkGreen);
		serviceFont.setFontWeight(QFont::Bold);
		QTextCharFormat incomingFont = cursor.charFormat();
		incomingFont.setForeground(Qt::red);
		incomingFont.setFontWeight(QFont::Bold);
		QTextCharFormat outgoingFont = cursor.charFormat();
		outgoingFont.setForeground(Qt::blue);
		outgoingFont.setFontWeight(QFont::Bold);
		const QString serviceMessageTitle = tr("Service message");
		const QString resultString = QStringLiteral("<span style='background: #ffff00'>\\1</span>");
		cursor.beginEditBlock();

		Account *account = findAccount(contactInfo);
		ChatUnit *unit = findContact(contactInfo);

		QString accountNickname = account ? account->name() : contactInfo.account;
		QString fromNickname = unit ? unit->title() : contactInfo.contact;
		int in_count = 0;
		int out_count = 0;

		for (const Message &message : messages) {
			bool service = message.property("service", false);
			QDateTime time = message.time();
			bool incoming = message.isIncoming();
			QString historyMessage = message.html();
			QString sender = message.property("senderName", incoming ? fromNickname : accountNickname);

			incoming ? in_count++ : out_count++;
			if (service) {
				cursor.setCharFormat(serviceFont);
				cursor.insertText(serviceMessageTitle);
			} else {
				cursor.setCharFormat(incoming ? incomingFont : outgoingFont);
				cursor.insertText(sender);
			}
			cursor.insertText(QStringLiteral(" (")
							  % time.toString(QStringLiteral("dd.MM.yyyy hh:mm:ss"))
							  % QStringLiteral(")"));
			cursor.setCharFormat(defaultFont);
			cursor.insertText(QStringLiteral("\n"));
			if (m_search_word.isEmpty()) {
				cursor.insertHtml(historyMessage);
				cursor.insertText(QStringLiteral("\n"));
			} else {
				cursor.insertHtml(historyMessage.replace(m_search, resultString));
				cursor.insertText(QStringLiteral("\n"));
			}
		}
		cursor.endEditBlock();
		doc->setParent(ui.historyLog);
		ui.historyLog->setDocument(doc);
		if (m_search_word.isEmpty())
			ui.historyLog->moveCursor(QTextCursor::End);
		else
			ui.historyLog->find(m_search_word);
		ui.historyLog->verticalScrollBar()->setValue(ui.historyLog->verticalScrollBar()->maximum());

		ui.label_in->setText(tr("In: %L1").arg(in_count));
		ui.label_out->setText(tr("Out: %L1").arg(out_count));
		ui.label_all->setText(tr("All: %L1").arg(in_count + out_count));
	});
}
开发者ID:CyberSys,项目名称:qutim,代码行数:93,代码来源:historywindow.cpp

示例10: Open

SOM_Scope long  SOMLINK Open(Bank *somSelf,  Environment *ev,
                             string name, long acct_type, long pin,
                             long amount)
{
    BankData *somThis = BankGetData(somSelf);
    BankMethodDebug("Bank","Open");

    Account *temp;
    somf_TSetIterator *itr;
    trans_info *Tr;
    somf_TSet *set;
    somf_TPrimitiveLinkedList *llist;
    char *user_name;

/* first check if the account already exists */
/* we create an iterator and walk through the account list */

   itr = new somf_TSetIterator;

   switch (acct_type)
   {
        case Account_CHECKING:
            itr->somfTSetIteratorInit(ev, somSelf->_get_check_acct_set(ev));
            break;
        case Account_SAVINGS:
            itr->somfTSetIteratorInit(ev, somSelf->_get_save_acct_set(ev));
            break;
        case Account_MF:
            itr->somfTSetIteratorInit(ev, somSelf->_get_mf_acct_set(ev));
            break;
        default:
            somPrintf (" bad account type\n");
            return 9;
   }

   temp = (Account *)itr->somfFirst(ev);
   while (temp != SOMF_NIL )
   {
       user_name = temp->_get_user_name(ev);
       if (strcmp(name, user_name) == 0) {          /* acct already exists ? */
              somPrintf("<%s> exists\n", name);
              return Account_ACCT_EXISTS;
       }
       else
            temp = (Account *)itr->somfNext(ev);
   }

/* if we are here then we need to add the account
 * initialize all values (hardwire interest and min_balance)
 * allocate space for the new account
 */
    user_name = (char *) malloc (strlen(name) + 1);
    strcpy (user_name, name);

    temp = new Account;
    temp->_set_user_name (ev, user_name);
    temp->_set_min_balance (ev, 0);
    temp->_set_act_balance (ev, amount);
    temp->_set_interest (ev, 5);
    temp->_set_pin (ev, pin);

   llist = new  somf_TPrimitiveLinkedList;
/* initialize the transaction list also */
   Tr = new trans_info;
   Tr->_set_amount (ev, amount);
   Tr->_set_transaction (ev, Account_OPEN);
   Tr->_set_date (ev, time(0));
   Tr->_set_curr_bal (ev, amount);
   llist->somfAddFirst(ev, Tr);

/* now set up all the information to point correctly */
   temp->_set_trans_list (ev, llist);

    /* now add the account to the appropriate set */
    if (acct_type == Account_CHECKING) {
         set = somSelf->_get_check_acct_set(ev);
         set->somfAdd(ev, temp);
    }
    else if (acct_type == Account_SAVINGS) {
         set = somSelf->_get_save_acct_set(ev);
         set->somfAdd(ev, temp);
    }
    else if (acct_type == Account_MF)  {
         set = somSelf->_get_mf_acct_set(ev);
         set->somfAdd(ev, temp);
    }

   itr->somFree();
    return Account_OK;
}
开发者ID:OS2World,项目名称:DEV-SAMPLES-SOM-IBM,代码行数:90,代码来源:BANK.CPP

示例11: memcpy

void AccountMgr::AddAccount(Field* field)
{
    Account* acct = new Account;
    Sha1Hash hash;
    std::string Username = field[1].GetString();
    std::string EncryptedPassword = field[2].GetString();
    std::string GMFlags = field[3].GetString();

    acct->AccountId = field[0].GetUInt32();
    acct->AccountFlags = field[4].GetUInt8();
    acct->Banned = field[5].GetUInt32();
    if ((uint32)UNIXTIME > acct->Banned && acct->Banned != 0 && acct->Banned != 1)   //1 = perm ban?
    {
        //Accounts should be unbanned once the date is past their set expiry date.
        acct->Banned = 0;
        //me go boom :(
        //printf("Account %s's ban has expired.\n",acct->UsernamePtr->c_str());
        sLogonSQL->Execute("UPDATE accounts SET banned = 0 WHERE acct=%u", acct->AccountId);
    }
    acct->SetGMFlags(GMFlags.c_str());
    acct->Locale[0] = 'e';
    acct->Locale[1] = 'n';
    acct->Locale[2] = 'U';
    acct->Locale[3] = 'S';
    if (strcmp(field[6].GetString(), "enUS"))
    {
        // non-standard language forced
        memcpy(acct->Locale, field[6].GetString(), 4);
        acct->forcedLocale = true;
    }
    else
        acct->forcedLocale = false;

    acct->Muted = field[7].GetUInt32();
    if ((uint32)UNIXTIME > acct->Muted && acct->Muted != 0 && acct->Muted != 1)   //1 = perm ban?
    {
        //Accounts should be unbanned once the date is past their set expiry date.
        acct->Muted = 0;
        //LOG_DEBUG("Account %s's mute has expired.",acct->UsernamePtr->c_str());
        sLogonSQL->Execute("UPDATE accounts SET muted = 0 WHERE acct=%u", acct->AccountId);
    }
    // Convert username to uppercase. this is needed ;)
    arcemu_TOUPPER(Username);

    // prefer encrypted passwords over nonencrypted
    if (EncryptedPassword.size() > 0)
    {
        if (EncryptedPassword.size() == 40)
        {
            BigNumber bn;
            bn.SetHexStr(EncryptedPassword.c_str());
            if (bn.GetNumBytes() < 20)
            {
                // Hacky fix
                memcpy(acct->SrpHash, bn.AsByteArray(), bn.GetNumBytes());
                for (int n = bn.GetNumBytes(); n <= 19; n++)
                    acct->SrpHash[n] = (uint8)0;
                reverse_array(acct->SrpHash, 20);
            }
            else
            {
                memcpy(acct->SrpHash, bn.AsByteArray(), 20);
                reverse_array(acct->SrpHash, 20);
            }
        }
        else
        {
            LOG_ERROR("Account `%s` has incorrect number of bytes in encrypted password! Disabling.", Username.c_str());
            memset(acct->SrpHash, 0, 20);
        }
    }
    else
    {
        // This should never happen...
        LOG_ERROR("Account `%s` has no encrypted password!", Username.c_str());
    }

    AccountDatabase[Username] = acct;
}
开发者ID:AriDEV,项目名称:AscEmu,代码行数:79,代码来源:AccountCache.cpp

示例12: Q_D

QString &WebKitMessageViewStyle::fillKeywordsForBaseTemplate(QString &inString, qutim_sdk_0_3::ChatSession *session)
{
	Q_D(WebKitMessageViewStyle);
	ChatUnit *unit = session->unit();
	Account *account = unit->account();
	Protocol *protocol = account->protocol();
	
	// FIXME: Should be session->title
	inString.replace(QLatin1String("%chatName%"), escapeString(unit->title()));
	inString.replace(QLatin1String("%sourceName%"), escapeString(account->name()));
	inString.replace(QLatin1String("%destinationName%"), escapeString(unit->id()));
	inString.replace(QLatin1String("%destinationDisplayName%"), escapeString(unit->title()));

	QString iconPath;
	
	inString.replace(QLatin1String("%incomingColor%"),
	                 WebKitColorsAdditions::representedColorForObject(unit->id(), validSenderColors()));
	inString.replace(QLatin1String("%outgoingColor%"),
	                 WebKitColorsAdditions::representedColorForObject(account->name(), validSenderColors()));
	
		
	iconPath = urlFromFilePath(unit->property("avatar").toString());
	if (iconPath.isEmpty()) {
		ChatUnit *contact = unit->upperUnit();
		while (contact && iconPath.isEmpty()) {
			iconPath = contact->property("avatar").toString();
			contact = contact->upperUnit();
		}
	}
	
	inString.replace(QLatin1String("%incomingIconPath%"),
	                 iconPath.isEmpty() ? QString::fromLatin1("incoming_icon.png") : iconPath);

	iconPath = urlFromFilePath(account->property("avatar").toString());
	inString.replace(QLatin1String("%outgoingIconPath%"),
	                 iconPath.isEmpty() ? QString::fromLatin1("outgoing_icon.png") : iconPath);

	// FIXME: Implement protocol.iconPath and protocol.shortDescription
	QString serviceIconPath = QString(); //account.protocol.iconPath;
	QString serviceIconTag = QString::fromLatin1("<img class=\"serviceIcon\" src=\"%1\" alt=\"%2\" title=\"%2\">")
	        .arg(serviceIconPath.isEmpty() ? QString::fromLatin1("outgoing_icon.png") : serviceIconPath, protocol->id() /*shortDescription*/ );
	
	inString.replace(QLatin1String("%serviceIconImg%"), serviceIconTag);
	inString.replace(QLatin1String("%serviceIconPath%"), serviceIconPath);
	inString.replace(QLatin1String("%timeOpened%"), convertTimeDate(d->timeStampFormatter, session->dateOpened()));
	
	//Replaces %time{x}% with a timestamp formatted like x (using NSDateFormatter)
	const QStringMatcher matcher(QLatin1String("%timeOpened{"));
	const int matcherSize = matcher.pattern().size();
	const QStringMatcher endMatcher(QLatin1String("}%"));
	const int endMatcherSize = endMatcher.pattern().size();
	int range = 0;
	do {
		range = matcher.indexIn(inString, range);
		if (range != -1) {
			int endRange = endMatcher.indexIn(inString, range + matcherSize);
			if (endRange != -1) {
				QString timeFormat = inString.mid(range + matcherSize, endRange - range - matcherSize);
				QString time = convertTimeDate(timeFormat, session->dateOpened());
				inString.replace(range, endRange + endMatcherSize - range, time);
				range = range + time.size();
			}
		}
	} while (range != -1);
	
	inString.replace(QLatin1String("%dateOpened%"), session->dateOpened().toString(Qt::SystemLocaleLongDate));
	
	//Background
	{
		QLatin1String bodyBackground("==bodyBackground==");
		range = inString.indexOf(bodyBackground);
		
		if (range != -1) { //a backgroundImage tag is not required
			QString bodyTag;

			if (d->allowsCustomBackground && (!d->customBackgroundPath.isEmpty() || d->customBackgroundColor.isValid())) {				
				if (!d->customBackgroundPath.isNull()) {
					if (d->customBackgroundPath.length() > 0) {
						switch (d->customBackgroundType) {
							case BackgroundNormal:
								bodyTag.append(QString::fromLatin1("background-image: url('%1'); background-repeat: no-repeat; background-attachment:fixed;").arg(d->customBackgroundPath));
							break;
							case BackgroundCenter:
								bodyTag.append(QString::fromLatin1("background-image: url('%1'); background-position: center; background-repeat: no-repeat; background-attachment:fixed;").arg(d->customBackgroundPath));
							break;
							case BackgroundTile:
								bodyTag.append(QString::fromLatin1("background-image: url('%1'); background-repeat: repeat;").arg(d->customBackgroundPath));
							break;
							case BackgroundTileCenter:
								bodyTag.append(QString::fromLatin1("background-image: url('%1'); background-repeat: repeat; background-position: center;").arg(d->customBackgroundPath));
							break;
							case BackgroundScale:
								bodyTag.append(QString::fromLatin1("background-image: url('%1'); -webkit-background-size: 100%% 100%%; background-size: 100%% 100%%; background-attachment: fixed;").arg(d->customBackgroundPath));
							break;
						}
					} else {
						bodyTag.append(QLatin1String("background-image: none; "));
					}
				}
				if (d->customBackgroundColor.isValid()) {
//.........这里部分代码省略.........
开发者ID:VladRassokhin,项目名称:qutim,代码行数:101,代码来源:webkitmessageviewstyle.cpp

示例13:

 friend bool operator == (Account const& fir, Account const& sec) {   // (1)
     return fir.getBalance() == sec.getBalance();
 }
开发者ID:RainerGrimm,项目名称:ModernesCppSource,代码行数:3,代码来源:accountRegular.cpp

示例14: getPreTransactionBalance

double TransactionServices::getPreTransactionBalance(int accId)
{
	Account* acc = _ds->getAccount(accId);
	return acc->getBalance();
}
开发者ID:bradbow,项目名称:BankingSystem,代码行数:5,代码来源:TransactionServices.cpp

示例15: switch

	///
	/// [1] Account Scripting Object Methods
	///
	///	 All methods except GetProp and GetCharacter return 1 on success
	///	 All methods except GetProp and GetCharacter write the accounts.txt file on success.
	///	 All methods return Error("Not enough parameters") if too few parameters were passed.
	///	 All methods return Error("Invalid parameter type") if the wrong type was passed.
	///
	Bscript::BObjectImp* AccountObjImp::call_method_id( const int id, Bscript::Executor& ex, bool forcebuiltin )
	{
	  using namespace Bscript;
	  BObjectImp* result = NULL;

	  switch ( id )
	  {
		case MTH_GET_MEMBER:
		{
		  if ( !ex.hasParams( 1 ) )
			return new BError( "Not enough parameters" );

		  const String* mname;
		  if ( ex.getStringParam( 0, mname ) )
		  {
			BObjectRef ref_temp = get_member( mname->value().c_str() );
			BObjectRef& ref = ref_temp;
			BObject *bo = ref.get();
			BObjectImp *ret = bo->impptr();
			ret = ret->copy();
			if ( ret->isa( OTUninit ) )
			{
			  string message = string( "Member " ) + string( mname->value() ) + string( " not found on that object" );
			  return new BError( message );
			}
			else
			{
			  return ret;
			}
		  }
		  else
			return new BError( "Invalid parameter type" );
		  break;
		}
		  ///	
		  /// account.Ban() : bans the account.  Disconnects connected client if any.
		  ///
		case MTH_BAN:
		  if ( ex.numParams() == 0 )
		  {
			obj_->banned_ = true;
			if ( obj_->active_character )
			{
			  if ( obj_->active_character->client )
				obj_->active_character->client->Disconnect();
			}
		  }
		  else
			return new BError( "account.Ban() doesn't take parameters." );
		  break;
		  ///
		  /// account.Unban() : unbans the account.
		  ///
		case MTH_UNBAN:
		  if ( ex.numParams() == 0 )
			obj_->banned_ = false;
		  else
			return new BError( "account.Unban() doesn't take parameters." );
		  break;
		  ///
		  /// account.Enable() : enables the account
		  ///
		case MTH_ENABLE:
		  if ( ex.numParams() == 0 )
			obj_->enabled_ = true;
		  else
			return new BError( "account.Enable() doesn't take parameters." );
		  break;
		  ///
		  /// account.Disable() : disables the account.  Disconnects connected client if any.
		  ///
		case MTH_DISABLE:
		  if ( ex.numParams() == 0 )
		  {
			obj_->enabled_ = false;
			if ( obj_->active_character )
			{
			  if ( obj_->active_character->client )
				obj_->active_character->client->Disconnect();
			}
			break;
		  }
		  else
			return new BError( "account.Disable() doesn't take parameters." );
		  ///
		  /// account.SetPassword( newpassword : string ) : changes the password..
		  ///
		case MTH_SETPASSWORD:
		  if ( ex.numParams() == 1 )
		  {
			const String* pwstr;
			if ( ex.getStringParam( 0, pwstr ) )
//.........这里部分代码省略.........
开发者ID:vitorfdl,项目名称:polserver,代码行数:101,代码来源:acscrobj.cpp


注:本文中的Account类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。