示例#1
0
QString PhysicalLocation::toString() const 
{
	QStringList locs;
	QString loc, str;
	if (!locality().isEmpty())
		locs += locality();

	if (!region().isEmpty())
		locs += region();

	if (!country().isEmpty())
		locs += country();

	if (!locs.isEmpty()) {
		loc = locs.join(", ");
	}
	 
	if (!text().isEmpty()) {
		str += text(); 
		if (!loc.isEmpty())
			str += " (";
	}

	str += loc;
		
	if (!text().isEmpty() && !loc.isEmpty())
		str += ")";

	return str;
}
示例#2
0
QString GeoLocation::translatedName() const {
    QString context;
    if( province().isEmpty() ) {
        context = QString("City in %1").arg(country());
    } else {
        context = QString("City in %1 %2").arg(province(), country());
    }
    return Name.isEmpty() ? QString() : i18nc(context.toUtf8().data(), Name.toUtf8().data());
}
示例#3
0
CommandResult
cmd_country (struct session *sess, gchar *tbuf, gchar *word[], gchar *word_eol[])
{
    gchar *code = word[2];
    if (*code)
    {
        /* search? */
        if (strcmp (code, "-s") == 0)
        {
            country_search (word[3], sess, (void *)PrintTextf);
            return CMD_EXEC_OK;
        }

        /* search, but forgot the -s */
        if (strchr (code, '*'))
        {
            country_search (code, sess, (void *)PrintTextf);
            return CMD_EXEC_OK;
        }

        sprintf (tbuf, "%s = %s\n", code, country (code));
        PrintText (sess, tbuf);
        return CMD_EXEC_OK;
    }
    return CMD_EXEC_FAIL;
}
示例#4
0
void TelegramGui::setCountry(const QString &cnt)
{
    if( country() == cnt.toLower() )
        return;

    tg_settings->setValue( "General/country", cnt.toLower() );
}
示例#5
0
    void LoginPage::init()
    {
        QMap<QString, QString> countryCodes = Utils::GetCountryCodes();
        combobox_->setEditBoxClass("CountrySearchEdit");
        combobox_->setComboboxViewClass("CountrySearchView");
        combobox_->setClass("CountySearchWidgetInternal");
        combobox_->setPlaceholder(QT_TRANSLATE_NOOP("login_page","Type country or code"));
        country_search_widget_->layout()->addWidget(combobox_);
        combobox_->setSources(countryCodes);

        connect(combobox_, SIGNAL(selected(QString)), this, SLOT(countrySelected(QString)), Qt::QueuedConnection);
        connect(this, SIGNAL(country(QString)), this, SLOT(redrawCountryCode()), Qt::QueuedConnection);
        connect(next_page_link_, SIGNAL(clicked()), this, SLOT(nextPage()), Qt::QueuedConnection);
        connect(prev_page_link_, SIGNAL(clicked()), this, SLOT(prevPage()), Qt::QueuedConnection);
        connect(edit_phone_button_, SIGNAL(clicked()), this, SLOT(prevPage()), Qt::QueuedConnection);
        connect(edit_phone_button_, SIGNAL(clicked()), this, SLOT(stats_edit_phone()), Qt::QueuedConnection);
        connect(switch_login_link_, SIGNAL(clicked()), this, SLOT(switchLoginType()), Qt::QueuedConnection);
        connect(resend_button_, SIGNAL(clicked()), this, SLOT(sendCode()), Qt::QueuedConnection);
        connect(resend_button_, SIGNAL(clicked()), this, SLOT(stats_resend_sms()), Qt::QueuedConnection);
        connect(timer_, SIGNAL(timeout()), this, SLOT(updateTimer()), Qt::QueuedConnection);

        connect(proxy_settings_link_, SIGNAL(clicked()), this, SLOT(openProxySettings()), Qt::QueuedConnection);

        country_code_->setProperty("CountryCodeEdit", true);
        phone_->setProperty("PhoneNumberEdit", true);
        phone_->setAttribute(Qt::WA_MacShowFocusRect, false);
        phone_->setPlaceholderText(QT_TRANSLATE_NOOP("login_page","your phone number"));
        phone_widget_->layout()->addWidget(country_code_);
        phone_widget_->layout()->addWidget(phone_);
        Testing::setAccessibleName(phone_, "StartWindowPhoneNumberField");

        connect(country_code_, SIGNAL(focusIn()), this, SLOT(setPhoneFocusIn()), Qt::QueuedConnection);
        connect(country_code_, SIGNAL(focusOut()), this, SLOT(setPhoneFocusOut()), Qt::QueuedConnection);
        connect(phone_, SIGNAL(focusIn()), this, SLOT(setPhoneFocusIn()), Qt::QueuedConnection);
        connect(phone_, SIGNAL(focusOut()), this, SLOT(setPhoneFocusOut()), Qt::QueuedConnection);

        connect(uin_login_edit_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(uin_password_edit_, SIGNAL(textEdited(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(code_edit_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(code_edit_, SIGNAL(textChanged(QString)), this, SLOT(codeEditChanged(QString)), Qt::QueuedConnection);
        connect(country_code_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(country_code_, SIGNAL(textEdited(QString)), this, SLOT(countryCodeChanged(QString)), Qt::QueuedConnection);
        connect(phone_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(phone_, SIGNAL(emptyTextBackspace()), this, SLOT(emptyPhoneRemove()), Qt::QueuedConnection);

        QObject::connect(Ui::GetDispatcher(), SIGNAL(getSmsResult(int64_t, int, int)), this, SLOT(getSmsResult(int64_t, int, int)), Qt::DirectConnection);
        QObject::connect(Ui::GetDispatcher(), SIGNAL(loginResult(int64_t, int)), this, SLOT(loginResult(int64_t, int)), Qt::DirectConnection);
        QObject::connect(Ui::GetDispatcher(), SIGNAL(loginResultAttachUin(int64_t, int)), this, SLOT(loginResultAttachUin(int64_t, int)), Qt::DirectConnection);
        QObject::connect(Ui::GetDispatcher(), SIGNAL(loginResultAttachPhone(int64_t, int)), this, SLOT(loginResultAttachPhone(int64_t, int)), Qt::DirectConnection);

        country_code_->setValidator(new QRegExpValidator(QRegExp("[\\+\\d]\\d*")));
        phone_->setValidator(new QRegExpValidator(QRegExp("\\d*")));
        code_edit_->setValidator(new QRegExpValidator(QRegExp("\\d*")));

        combobox_->selectItem(Utils::GetTranslator()->getCurrentPhoneCode());
        error_label_->hide();
        phone_->setFocus();
        country_code_->setFocusPolicy(Qt::ClickFocus);
        initLoginSubPage(SUBPAGE_PHONE_LOGIN_INDEX);
    }
示例#6
0
    void LoginPage::getSmsResult(int64_t _seq, int result, int _code_length)
    {
        if (_seq != send_seq_)
            return;

        country_code_->setEnabled(true);
        phone_->setEnabled(true);
        setErrorText(result);
        error_label_->setVisible(result);
        if (result == core::le_success)
        {
            if (_code_length != 0)
                code_length_ = _code_length;
            clearErrors();
            return initLoginSubPage(SUBPAGE_PHONE_CONF_INDEX);
        }

        phone_widget_->setProperty("EnterPhoneWidgetError", true);
        phone_widget_->setProperty("EnterPhoneWidgetFocused", false);
        phone_widget_->setProperty("EnterPhoneWidget", false);
        phone_widget_->setStyle(QApplication::style());
        phone_->setProperty("PhoneNumberError", true);
        phone_->setStyle(QApplication::style());
        emit country(country_code_->text());
    }
示例#7
0
文件: phrase.cpp 项目: Suneal/qt
bool PhraseBook::save(const QString &fileName)
{
    QFile f(fileName);
    if (!f.open(QIODevice::WriteOnly))
        return false;

    m_fileName = fileName;

    QTextStream t(&f);
    t.setCodec( QTextCodec::codecForName("UTF-8") );

    t << "<!DOCTYPE QPH>\n<QPH";
    if (sourceLanguage() != QLocale::C)
        t << " sourcelanguage=\""
          << Translator::makeLanguageCode(sourceLanguage(), sourceCountry()) << '"';
    if (language() != QLocale::C)
        t << " language=\"" << Translator::makeLanguageCode(language(), country()) << '"';
    t << ">\n";
    foreach (Phrase *p, m_phrases) {
        t << "<phrase>\n";
        t << "    <source>" << protect( p->source() ) << "</source>\n";
        t << "    <target>" << protect( p->target() ) << "</target>\n";
        if (!p->definition().isEmpty())
            t << "    <definition>" << protect( p->definition() )
              << "</definition>\n";
        t << "</phrase>\n";
    }
static jboolean android_net_wifi_setCountryCodeCommand(JNIEnv* env, jobject, jstring javaCountry)
{
    ScopedUtfChars country(env, javaCountry);
    if (country.c_str() == NULL) {
        return JNI_FALSE;
    }
    return doBooleanCommand("OK", "DRIVER COUNTRY %s", country.c_str());
}
示例#9
0
 void LoginPage::setPhoneFocusOut()
 {
     phone_widget_->setProperty("EnterPhoneWidgetFocused", false);
     phone_widget_->setProperty("EnterPhoneWidgetError", false);
     phone_widget_->setProperty("EnterPhoneWidget", true);
     phone_widget_->setStyle(QApplication::style());
     emit country(country_code_->text());
 }
void CoverConnector::setCountry(const QString &nCountry)
{
    if (nCountry != m_country) {
        m_country = nCountry;
#ifdef QT_DEBUG
        qDebug() << "Changed country to" << m_country;
#endif
        emit countryChanged(country());
    }
}
Time::Time(const CString& timeStr):
ti(0)
{
	long hours=0, mins=0, seconds=0;
#if defined(__BORLANDC__) && !defined(__WIN32__)
	// TODO: get country info under DJGPP & Win32
	COUNTRY	countryInfo;

	country(0, &countryInfo);
#endif

	if (timeStr == timeFormat1)
		{
		sscanf(timeStr, "%ld%*c%ld", &hours, &mins);
		}

	if (timeStr == timeFormat2)
		{
		sscanf(timeStr, "%ld%*c%ld%*c%ld", &hours, &mins, &seconds);
		}

#if defined(__BORLANDC__) && !defined(__WIN32__)
	if (countryInfo.co_time == 0)
#else
	// TODO: get country info under DJGPP & Win32
	if (0 == 0) 
#endif
		{
		char	ampm = '\0';

		if (timeStr == timeFormat3)
			{
			sscanf(timeStr, "%ld%*c%ld%c", &hours, &mins, &ampm);
			}

		if (timeStr == timeFormat4)
			{
			sscanf(timeStr, "%ld%*c%ld%*c%ld%c", &hours, &mins, &seconds, &ampm);
			}

		if ((ampm == 'p' || ampm == 'P') && hours < 12)
			{
			hours += 12;
			}

		if ((ampm == 'a' || ampm == 'A') && hours == 12)
			{
			hours = 0;
			}
		}

	ti = long(seconds) + (long(mins)*60) + (long(hours)*60*60);
}
Time::operator CString() const
{
#if defined(__BORLANDC__) && !defined(__WIN32__)
	// TODO: get country info under DJGPP & Win32
	COUNTRY	countryInfo;

	country(0, &countryInfo);
#endif

#if defined(__BORLANDC__) && !defined(__WIN32__)
	// TODO: get country info under DJGPP & Win32
	switch (countryInfo.co_time)
#else
	switch (0)
#endif		
		{
		case 1:
			{
			MTrace(("Time=%s", (const char*)sformat("%02i%s%02i", hours(), ":", minutes())));
			return sformat("%02i%s%02i", hours(), ":", minutes());
			}

		case 0:
			{
			if (hours() == 0)
				{
				MTrace(("Time=%s", (const char*)sformat("12%s%02iam", ":", minutes())));
				return sformat("12%s%02iam", ":", minutes());
				}

			if (hours() == 12)
				{
				MTrace(("Time=%s", (const char*)sformat("12%s%02ipm", ":", minutes())));
				return sformat("12%s%02ipm", ":", minutes());
				}

			if (hours() > 12)
				{
				MTrace(("Time=%s", (const char*)sformat("%02i%s%02ipm", hours()-12, ":", minutes())));
				return sformat("%02i%s%02ipm", hours()-12, ":", minutes());
				}

			if (hours() < 12)
				{
				MTrace(("Time=%s", (const char*)sformat("%02i%s%02iam", hours(), ":", minutes())));
				return sformat("%02i%s%02iam", hours(), ":", minutes());
				}
			}
		}

	return CString();
}
CountryCollection::CountryCollection(const CK2::TitleCollection& titles, const CK2::CharacterCollection& characters, const CK2::DynastyCollection& dynasties)
{
  LOG(LogLevel::Info) << "Creating EU4 countries";
  auto topLevelTitles = titles.GetAllTopLevelTitles();
  for (const auto& titleID : topLevelTitles)
  {
    const auto& title = titles.GetTitle(titleID);
    auto countryTag = titleCountryMapping.AddTitleAsNewCountry(titleID);
    EU4::Country country(countryTag, title, characters, dynasties);
    countries.emplace(countryTag, std::move(country));
    LOG(LogLevel::Debug) << "CK2 title " << titleID << " converted to country tag " << countryTag;
  }
}
示例#14
0
	void LoginPage::clearErrors()
	{
		error_label_->hide();

		uin_login_edit_->setProperty("UinError", false);
		uin_login_edit_->setProperty("Uin", true);
		uin_login_edit_->setStyle(QApplication::style());

		code_edit_->setProperty("EnteredCodeError", false);
		code_edit_->setProperty("EnteredCode", true);
		code_edit_->setStyle(QApplication::style());

		emit country(country_code_->text());
	}
示例#15
0
void
QuasarConfig::slotLocaleChange()
{
    Locale locale;
    if (_locale->currentItem() == 0)
	locale = systemLocale;
    else
	locale = _locales[_locale->currentItem() - 1];

    QString localesDir = QuasarClient::localesDir();
    QString language(locale.getLanguage());
    QString country(locale.getCountry());

    bool found = false;
    QTranslator translator(0);
    if (!country.isEmpty()) {
	QString dir = localesDir + "/" + language + "_" + country;
	if (translator.load("messages.qm", dir))
	    found = true;
    }
    if (!found) {
	QString dir = localesDir + "/" + language;
	if (translator.load("messages.qm", dir))
	    found = true;
    }
    if (!found) {
	QString message = tr("Quasar has not been localized for this\n"
			     "locale so the text of the program will\n"
			     "not change but the date, time, number,\n"
			     "currency, and percent should be properly\n"
			     "localized.");
	QMessageBox::warning(this, tr("Warning"), message);
    }

    // Set default locale for ICU
    UErrorCode status = U_ZERO_ERROR;
    Locale::setDefault(locale, status);
    if (U_FAILURE(status)) {
	QString msg = tr("Failed setting locale to %1").arg(locale.getName());
	QMessageBox::critical(this, tr("Error"), msg);
    }

    loadLocales();
    setSamples();
}
CString Time::longCString() const
{
#if defined(__BORLANDC__) && !defined(__WIN32__)
	// TODO: get country info under DJGPP & Win32
	COUNTRY	countryInfo;

	country(0, &countryInfo);
#endif

#if defined(__BORLANDC__) && !defined(__WIN32__)
	// TODO: get country info under DJGPP & Win32
	switch (countryInfo.co_time)
#else	
	switch (0)
#endif
		{
		case 1:
			return sformat("%02i%s%02i%s%02i", hours(), ":", minutes(), ":", seconds());

		case 0:
			{
			if (hours() == 0)
				{
				return sformat("12%s%02i%s%02iam", ":", minutes(), ":", seconds());
				}

			if (hours() == 12)
				{
				return sformat("12%s%02i%s%02ipm", ":", minutes(), ":", seconds());
				}

			if (hours() > 12)
				{
				return sformat("%02i%s%02i%s%02ipm", hours()-12, ":", minutes(), ":", seconds());
				}

			if (hours() < 12)
				{
				return sformat("%02i%s%02i%s%02iam", hours(), ":", minutes(), ":", seconds());
				}
			}
		}

	return CString();
}
示例#17
0
void
BootPromptWindow::_InitCatalog(bool saveSettings)
{
	// Initilialize the Locale Kit
	// TODO: The below code is a work-around for not being able to
	// call GetAppCatalog() more than once.
	be_catalog = be_app_catalog = NULL;
	// NOTE: be_catalog and be_app_catalog will point fo &fCatalog!

	be_locale->GetAppCatalog(&fCatalog);

	// Generate a settings file
	// TODO: This should not be necessary.
	// be_locale_roster->SetPreferredLanguages() should take care of things
	if (!saveSettings)
		return;

	BPath path;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
		|| path.Append("Locale settings") != B_OK) {
		return;
	}

	BMessage settings;

	BFile file;
	if (file.SetTo(path.Path(), B_READ_ONLY) == B_OK)
		settings.Unflatten(&file);

	BString language;
	if (fCatalog.GetLanguage(&language) == B_OK) {
		settings.RemoveName("language");
		settings.AddString("language", language.String());
	}

	settings.RemoveName("country");
	BCountry country(language.String(), language.ToUpper());
	settings.AddString("country", country.Code());

	if (file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY)
			!= B_OK
		|| settings.Flatten(&file) != B_OK) {
		fprintf(stderr, "Failed to write Local Kit settings!\n");
	}
}
示例#18
0
void TorrifyWindow::updateUI()
{
    bool isRunning = false;
    bool isSelected = false;
    auto index = ui->treeView->currentIndex();
    if (index != QModelIndex() && index.parent() == QModelIndex())
    {
        auto tor = reinterpret_cast<TorInstance*>(ui->treeView->currentIndex().internalPointer());
        if (tor)
        {
            isSelected = true;
            isRunning = tor->isRunning();

            if (isRunning)
            {
                ui->valueIP->setText(tor->ip());
                ui->valueCountry->setText(tor->country());
                ui->valueGeo->setText(tor->location());
                ui->googleMaps->setPixmap(tor->map());
            }
            ui->valuePort->setText(tor->port());
        }
    }

    if (!isRunning)
    {
        ui->valueIP->setText("N/A");
        ui->valueCountry->setText("N/A");
        ui->valueGeo->setText("N/A");
        ui->googleMaps->setPixmap(QPixmap());
        ui->googleMaps->setText("Location unknown");
    }
    if (!isSelected)
    {
        ui->valuePort->setText("N/A");
    }

    ui->treeView->dataChanged(QModelIndex(), QModelIndex());

    ui->actionDelete_Tor_instance->setEnabled(isSelected);
    ui->actionRun_Tor_instance->setEnabled(!isRunning && isSelected);
    ui->actionStop_Tor_instance->setEnabled(isRunning && isSelected);
    ui->actionChange_identity->setEnabled(isRunning && isSelected);
    ui->settingsFrame->setEnabled(isSelected);
}
示例#19
0
	void LoginPage::getSmsResult(int result)
	{
		country_code_->setEnabled(true);
		phone_->setEnabled(true);
		setErrorText(result);
		error_label_->setVisible(result);
		if (result == core::le_success)
		{
			clearErrors();
			return initLoginSubPage(SUBPAGE_PHONE_CONF_INDEX);
		}

		phone_widget_->setProperty("EnterPhoneWidgetError", true);
		phone_widget_->setProperty("EnterPhoneWidgetFocused", false);
		phone_widget_->setProperty("EnterPhoneWidget", false);
		phone_widget_->setStyle(QApplication::style());
		emit country(country_code_->text());
	}
示例#20
0
文件: 141.C 项目: JackDrogon/Study
void main(void)
{
	struct country info;
	clrscr();
	puts(" This program is to get the country information:");
	country(0, &info);

	if (info.co_date == 0)
		printf(" >> Date format: mm/dd/yy\n");
	else if (info.co_date == 1)
		printf(" >> Date format: dd/mm/yy\n");
	else if (info.co_date == 2)
		printf(" >> Date format: yy/mm/dd\n");

	printf(" >> Currency symbol %s\n", info.co_curr);
	printf(" >> Decimal separator %s\n", info.co_thsep);
	printf(" >> Date separator %s Time separator %s\n",
		info.co_dtsep, info.co_tmsep);

	if (info.co_currstyle == 0)
		printf(" >> Currency symbol precedes with no leading spaces\n");
	else if (info.co_currstyle == 1)
		printf(" >> Currency symbol follows with no spaces\n");
	else if (info.co_currstyle == 2)
		printf(" >> Currency symbol precedes with leading space\n");
	if (info.co_currstyle == 4)
		printf(" >> Currency symbol follows with space\n");

	printf(" >> Currency significant digits %d\n", info.co_digits);

	if (info.co_time)
		printf(" >> 24 hour time\n");
	else
		printf(" >> 12 hour time\n");

	printf(" >> Data separator %s\n", info.co_dasep);
	printf(" Press any key to quit...");
	getch();
}
示例#21
0
INT_PTR CALLBACK CSkypeProto::HomeSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	const unsigned long iPageId = 2;
	CSkypeProto *ppro = (CSkypeProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch (msg) {
	case WM_INITDIALOG:
		if (lParam) {
			ppro = (CSkypeProto *)lParam;
			::TranslateDialogDefault(hwndDlg);

			::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);

			DBVARIANT dbv;
			if ( !ppro->getTString("City", &dbv)) {
				::SetDlgItemText(hwndDlg, IDC_CITY, dbv.ptszVal);
				::db_free(&dbv);
			}
			else ::SetDlgItemText(hwndDlg, IDC_CITY, _T(""));

			if ( !ppro->getTString("State", &dbv)) {
				::SetDlgItemText(hwndDlg, IDC_STATE, dbv.ptszVal);
				::db_free(&dbv);
			}
			else ::SetDlgItemText(hwndDlg, IDC_STATE, _T(""));

			ptrW countr(::db_get_wsa(NULL, ppro->m_szModuleName, "Country"));
			for (int i = 0; i < g_cbCountries; i++)
			{
				if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0)
				{
					ptrT country( mir_a2t(g_countries[i].szName));
					int nItem = ::SendMessage(
						::GetDlgItem(hwndDlg, IDC_COUNTRY), 
						CB_ADDSTRING, 
						0, 
						(LPARAM)::TranslateTS(country));
					
					::SendMessage(
						::GetDlgItem(hwndDlg, IDC_COUNTRY), 
						CB_SETITEMDATA, 
						nItem, 
						(LPARAM)&g_countries[i].ISOcode);

					if (countr && ::wcscmp(country, countr) == 0)
						::SendMessage(GetDlgItem(hwndDlg, IDC_COUNTRY), CB_SETCURSEL, nItem, 0);
				}
			}

			tmi.prepareList((HANDLE)lParam, ::GetDlgItem(hwndDlg, IDC_TIMEZONE), TZF_PLF_CB);
			HANDLE hTimeZone = tmi.createByContact ? tmi.createByContact(NULL, 0) : 0;
			LPCTSTR TzDescr = tmi.getTzDescription(tmi.getTzName(hTimeZone));
			::SetDlgItemText(hwndDlg, IDC_TIMEZONE, TzDescr);
		}
		break;

	case WM_COMMAND:
		if (((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) ||
			(((HWND)lParam == GetDlgItem(hwndDlg, IDC_COUNTRY) || (HWND)lParam == GetDlgItem(hwndDlg, IDC_TIMEZONE)) &&
			(HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE)))
		{
			ppro->NeedUpdate = 1;
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
		}
		break;

	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->idFrom == 0) {
			switch (((LPNMHDR)lParam)->code) {
			case PSN_PARAMCHANGED:
				SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY *)lParam)->lParam);
				break;
			case PSN_APPLY:
				if (ppro->IsOnline() && ppro->NeedUpdate)
					ppro->SaveOwnInfoToServer(hwndDlg, iPageId);
				else if ( !ppro->IsOnline())
					ppro->ShowNotification(::TranslateT("You are not currently connected to the Skype network. You must be online in order to update your information on the server."));
				break;
			}
		}
		break;
	}
	return FALSE;
}
示例#22
0
void CVideoInfoTag::ParseNative(const TiXmlElement* movie, bool prioritise)
{
  std::string value;
  float fValue;

  if (XMLUtils::GetString(movie, "title", value))
    SetTitle(value);

  if (XMLUtils::GetString(movie, "originaltitle", value))
    SetOriginalTitle(value);

  if (XMLUtils::GetString(movie, "showtitle", value))
    SetShowTitle(value);

  if (XMLUtils::GetString(movie, "sorttitle", value))
    SetSortTitle(value);

  const TiXmlElement* node = movie->FirstChildElement("ratings");
  if (node)
  {
    for (const TiXmlElement* child = node->FirstChildElement("rating"); child != nullptr; child = child->NextSiblingElement("rating"))
    {
      CRating r;
      std::string name;
      if (child->QueryStringAttribute("name", &name) != TIXML_SUCCESS)
        name = "default";
      XMLUtils::GetFloat(child, "value", r.rating);
      XMLUtils::GetInt(child, "votes", r.votes);
      int max_value = 10;
      if ((child->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value >= 1)
        r.rating = r.rating / max_value * 10; // Normalise the Movie Rating to between 1 and 10
      SetRating(r, name);
      bool isDefault = false;
      if ((child->QueryBoolAttribute("default", &isDefault) == TIXML_SUCCESS) && isDefault)
        m_strDefaultRating = name;
    }
  }
  else if (XMLUtils::GetFloat(movie, "rating", fValue))
  {
    CRating r(fValue, 0);
    if (XMLUtils::GetString(movie, "votes", value))
      r.votes = StringUtils::ReturnDigits(value);
    int max_value = 10;
    const TiXmlElement* rElement = movie->FirstChildElement("rating");
    if (rElement && (rElement->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value >= 1)
      r.rating = r.rating / max_value * 10; // Normalise the Movie Rating to between 1 and 10
    SetRating(r, "default");
    m_strDefaultRating = "default";
  }
  XMLUtils::GetInt(movie, "userrating", m_iUserRating);

  const TiXmlElement *epbookmark = movie->FirstChildElement("episodebookmark");
  if (epbookmark)
  {
    XMLUtils::GetDouble(epbookmark, "position", m_EpBookmark.timeInSeconds);
    const TiXmlElement *playerstate = epbookmark->FirstChildElement("playerstate");
    if (playerstate)
    {
      const TiXmlElement *value = playerstate->FirstChildElement();
      if (value)
        m_EpBookmark.playerState << *value;
    }
  }
  else
    XMLUtils::GetDouble(movie, "epbookmark", m_EpBookmark.timeInSeconds);

  int max_value = 10;
  const TiXmlElement* urElement = movie->FirstChildElement("userrating");
  if (urElement && (urElement->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value >= 1)
    m_iUserRating = m_iUserRating / max_value * 10; // Normalise the user Movie Rating to between 1 and 10
  XMLUtils::GetInt(movie, "top250", m_iTop250);
  XMLUtils::GetInt(movie, "season", m_iSeason);
  XMLUtils::GetInt(movie, "episode", m_iEpisode);
  XMLUtils::GetInt(movie, "track", m_iTrack);

  XMLUtils::GetInt(movie, "displayseason", m_iSpecialSortSeason);
  XMLUtils::GetInt(movie, "displayepisode", m_iSpecialSortEpisode);
  int after=0;
  XMLUtils::GetInt(movie, "displayafterseason",after);
  if (after > 0)
  {
    m_iSpecialSortSeason = after;
    m_iSpecialSortEpisode = 0x1000; // should be more than any realistic episode number
  }

  if (XMLUtils::GetString(movie, "outline", value))
    SetPlotOutline(value);

  if (XMLUtils::GetString(movie, "plot", value))
    SetPlot(value);

  if (XMLUtils::GetString(movie, "tagline", value))
    SetTagLine(value);

  
  if (XMLUtils::GetString(movie, "runtime", value) && !value.empty())
    m_duration = GetDurationFromMinuteString(StringUtils::Trim(value));
  
  if (XMLUtils::GetString(movie, "mpaa", value))
    SetMPAARating(value);

  XMLUtils::GetInt(movie, "playcount", m_playCount);
  XMLUtils::GetDate(movie, "lastplayed", m_lastPlayed);
  
  if (XMLUtils::GetString(movie, "file", value))
    SetFile(value);

  if (XMLUtils::GetString(movie, "path", value))
    SetPath(value);

  const TiXmlElement* uniqueid = movie->FirstChildElement("uniqueid");
  if (uniqueid == nullptr)
  {
    if (XMLUtils::GetString(movie, "id", value))
      SetUniqueID(value);
  }
  else
  {
    for (; uniqueid != nullptr; uniqueid = uniqueid->NextSiblingElement("uniqueid"))
    {
      if (uniqueid->FirstChild())
      {
      if (uniqueid->QueryStringAttribute("type", &value) == TIXML_SUCCESS)
        SetUniqueID(uniqueid->FirstChild()->ValueStr(), value);
      else
        SetUniqueID(uniqueid->FirstChild()->ValueStr());
      bool isDefault;
      if ((uniqueid->QueryBoolAttribute("default", &isDefault) == TIXML_SUCCESS) && isDefault)
        m_strDefaultUniqueID = value;
      }
    }
  }

  if (XMLUtils::GetString(movie, "filenameandpath", value))
    SetFileNameAndPath(value);

  if (XMLUtils::GetDate(movie, "premiered", m_premiered))
  {
    m_bHasPremiered = true;
  }
  else
  {
    int year;
    if (XMLUtils::GetInt(movie, "year", year))
      SetYear(year);
  }
  
  if (XMLUtils::GetString(movie, "status", value))
    SetStatus(value);

  if (XMLUtils::GetString(movie, "code", value))
    SetProductionCode(value);

  XMLUtils::GetDate(movie, "aired", m_firstAired);
  
  if (XMLUtils::GetString(movie, "album", value))
    SetAlbum(value);

  if (XMLUtils::GetString(movie, "trailer", value))
    SetTrailer(value);

  if (XMLUtils::GetString(movie, "basepath", value))
    SetBasePath(value);

  size_t iThumbCount = m_strPictureURL.m_url.size();
  std::string xmlAdd = m_strPictureURL.m_xml;

  const TiXmlElement* thumb = movie->FirstChildElement("thumb");
  while (thumb)
  {
    m_strPictureURL.ParseElement(thumb);
    if (prioritise)
    {
      std::string temp;
      temp << *thumb;
      xmlAdd = temp+xmlAdd;
    }
    thumb = thumb->NextSiblingElement("thumb");
  }

  // prioritise thumbs from nfos
  if (prioritise && iThumbCount && iThumbCount != m_strPictureURL.m_url.size())
  {
    rotate(m_strPictureURL.m_url.begin(),
           m_strPictureURL.m_url.begin()+iThumbCount, 
           m_strPictureURL.m_url.end());
    m_strPictureURL.m_xml = xmlAdd;
  }

  std::vector<std::string> genres(m_genre);
  if (XMLUtils::GetStringArray(movie, "genre", genres, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetGenre(genres);

  std::vector<std::string> country(m_country);
  if (XMLUtils::GetStringArray(movie, "country", country, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetCountry(country);

  std::vector<std::string> credits(m_writingCredits);
  if (XMLUtils::GetStringArray(movie, "credits", credits, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetWritingCredits(credits);

  std::vector<std::string> director(m_director);
  if (XMLUtils::GetStringArray(movie, "director", director, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetDirector(director);

  std::vector<std::string> showLink(m_showLink);
  if (XMLUtils::GetStringArray(movie, "showlink", showLink, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetShowLink(showLink);

  const TiXmlElement* namedSeason = movie->FirstChildElement("namedseason");
  while (namedSeason != nullptr)
  {
    if (namedSeason->FirstChild() != nullptr)
    {
      int seasonNumber;
      std::string seasonName = namedSeason->FirstChild()->ValueStr();
      if (!seasonName.empty() &&
          namedSeason->Attribute("number", &seasonNumber) != nullptr)
        m_namedSeasons.insert(std::make_pair(seasonNumber, seasonName));
    }

    namedSeason = namedSeason->NextSiblingElement("namedseason");
  }

  // cast
  node = movie->FirstChildElement("actor");
  if (node && node->FirstChild() && prioritise)
    m_cast.clear();
  while (node)
  {
    const TiXmlNode *actor = node->FirstChild("name");
    if (actor && actor->FirstChild())
    {
      SActorInfo info;
      info.strName = actor->FirstChild()->Value();
      
      if (XMLUtils::GetString(node, "role", value))
        info.strRole = StringUtils::Trim(value);
      
      XMLUtils::GetInt(node, "order", info.order);
      const TiXmlElement* thumb = node->FirstChildElement("thumb");
      while (thumb)
      {
        info.thumbUrl.ParseElement(thumb);
        thumb = thumb->NextSiblingElement("thumb");
      }
      const char* clear=node->Attribute("clear");
      if (clear && stricmp(clear,"true"))
        m_cast.clear();
      m_cast.push_back(info);
    }
    node = node->NextSiblingElement("actor");
  }

  // Pre-Jarvis NFO file:
  // <set>A set</set>
  if (XMLUtils::GetString(movie, "set", value))
    SetSet(value);
  // Jarvis+:
  // <set><name>A set</name><overview>A set with a number of movies...</overview></set>
  node = movie->FirstChildElement("set");
  if (node)
  {
    // No name, no set
    if (XMLUtils::GetString(node, "name", value))
    {
      SetSet(value);
      if (XMLUtils::GetString(node, "overview", value))
        SetSetOverview(value);
    }
  }

  std::vector<std::string> tags(m_tags);
  if (XMLUtils::GetStringArray(movie, "tag", tags, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetTags(tags);

  std::vector<std::string> studio(m_studio);
  if (XMLUtils::GetStringArray(movie, "studio", studio, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetStudio(studio);

  // artists
  std::vector<std::string> artist(m_artist);
  node = movie->FirstChildElement("artist");
  if (node && node->FirstChild() && prioritise)
    artist.clear();
  while (node)
  {
    const TiXmlNode* pNode = node->FirstChild("name");
    const char* pValue=NULL;
    if (pNode && pNode->FirstChild())
      pValue = pNode->FirstChild()->Value();
    else if (node->FirstChild())
      pValue = node->FirstChild()->Value();
    if (pValue)
    {
      const char* clear=node->Attribute("clear");
      if (clear && stricmp(clear,"true")==0)
        artist.clear();
      std::vector<std::string> newArtists = StringUtils::Split(pValue, g_advancedSettings.m_videoItemSeparator);
      artist.insert(artist.end(), newArtists.begin(), newArtists.end());
    }
    node = node->NextSiblingElement("artist");
  }
  SetArtist(artist);

  node = movie->FirstChildElement("fileinfo");
  if (node)
  {
    // Try to pull from fileinfo/streamdetails/[video|audio|subtitle]
    const TiXmlNode *nodeStreamDetails = node->FirstChild("streamdetails");
    if (nodeStreamDetails)
    {
      const TiXmlNode *nodeDetail = NULL;
      while ((nodeDetail = nodeStreamDetails->IterateChildren("audio", nodeDetail)))
      {
        CStreamDetailAudio *p = new CStreamDetailAudio();
        if (XMLUtils::GetString(nodeDetail, "codec", value))
          p->m_strCodec = StringUtils::Trim(value);

        if (XMLUtils::GetString(nodeDetail, "language", value))
          p->m_strLanguage = StringUtils::Trim(value);

        XMLUtils::GetInt(nodeDetail, "channels", p->m_iChannels);
        StringUtils::ToLower(p->m_strCodec);
        StringUtils::ToLower(p->m_strLanguage);
        m_streamDetails.AddStream(p);
      }
      nodeDetail = NULL;
      while ((nodeDetail = nodeStreamDetails->IterateChildren("video", nodeDetail)))
      {
        CStreamDetailVideo *p = new CStreamDetailVideo();
        if (XMLUtils::GetString(nodeDetail, "codec", value))
          p->m_strCodec = StringUtils::Trim(value);

        XMLUtils::GetFloat(nodeDetail, "aspect", p->m_fAspect);
        XMLUtils::GetInt(nodeDetail, "width", p->m_iWidth);
        XMLUtils::GetInt(nodeDetail, "height", p->m_iHeight);
        XMLUtils::GetInt(nodeDetail, "durationinseconds", p->m_iDuration);
        if (XMLUtils::GetString(nodeDetail, "stereomode", value))
          p->m_strStereoMode = StringUtils::Trim(value);
        if (XMLUtils::GetString(nodeDetail, "language", value))
          p->m_strLanguage = StringUtils::Trim(value);

        StringUtils::ToLower(p->m_strCodec);
        StringUtils::ToLower(p->m_strStereoMode);
        StringUtils::ToLower(p->m_strLanguage);
        m_streamDetails.AddStream(p);
      }
      nodeDetail = NULL;
      while ((nodeDetail = nodeStreamDetails->IterateChildren("subtitle", nodeDetail)))
      {
        CStreamDetailSubtitle *p = new CStreamDetailSubtitle();
        if (XMLUtils::GetString(nodeDetail, "language", value))
          p->m_strLanguage = StringUtils::Trim(value);
        StringUtils::ToLower(p->m_strLanguage);
        m_streamDetails.AddStream(p);
      }
    }
    m_streamDetails.DetermineBestStreams();
  }  /* if fileinfo */

  const TiXmlElement *epguide = movie->FirstChildElement("episodeguide");
  if (epguide)
  {
    // DEPRECIATE ME - support for old XML-encoded <episodeguide> blocks.
    if (epguide->FirstChild() && strnicmp("<episodeguide", epguide->FirstChild()->Value(), 13) == 0)
      m_strEpisodeGuide = epguide->FirstChild()->Value();
    else
    {
      std::stringstream stream;
      stream << *epguide;
      m_strEpisodeGuide = stream.str();
    }
  }

  // fanart
  const TiXmlElement *fanart = movie->FirstChildElement("fanart");
  if (fanart)
  {
    // we prioritise mixed-mode nfo's with fanart set
    if (prioritise)
    {
      std::string temp;
      temp << *fanart;
      m_fanart.m_xml = temp+m_fanart.m_xml;
    }
    else
      m_fanart.m_xml << *fanart;
    m_fanart.Unpack();
  }

  // resumePoint
  const TiXmlNode *resume = movie->FirstChild("resume");
  if (resume)
  {
    XMLUtils::GetDouble(resume, "position", m_resumePoint.timeInSeconds);
    XMLUtils::GetDouble(resume, "total", m_resumePoint.totalTimeInSeconds);
  }

  XMLUtils::GetDateTime(movie, "dateadded", m_dateAdded);
}
示例#23
0
void Sav6::trade(std::shared_ptr<PKX> pk)
{
    PK6 *pk6 = (PK6*)pk.get();
    if (pk6->egg())
    {
        if (otName() != pk6->otName() || TID() != pk6->TID() || SID() != pk6->SID() || gender() != pk6->otGender())
        {
            pk6->metDay(Configuration::getInstance().day());
            pk6->metMonth(Configuration::getInstance().month());
            pk6->metYear(Configuration::getInstance().year() - 2000);
            pk6->metLocation(30002);
        }
        return;
    }
    else if (otName() == pk6->otName() && TID() == pk6->TID() && SID() == pk6->SID() && gender() == pk6->otGender())
    {
        pk6->currentHandler(0);

        if (!pk6->untraded() && (country() != pk6->geoCountry(0) || subRegion() != pk6->geoRegion(0)))
        {
            for (int i = 4; i > 0; i--)
            {
                pk6->geoCountry(pk6->geoCountry(i - 1), i);
                pk6->geoRegion(pk6->geoRegion(i - 1), i);
            }
            pk6->geoCountry(country());
            pk6->geoRegion(subRegion());
        }
    }
    else
    {
        if (otName() != pk6->htName() || gender() != pk6->htGender() || (pk6->geoCountry(0) == 0 && pk6->geoRegion(0) == 0 && !pk6->untradedEvent()))
        {
            for (int i = 4; i > 0; i--)
            {
                pk6->geoCountry(pk6->geoCountry(i - 1), i);
                pk6->geoRegion(pk6->geoRegion(i - 1), i);
            }
            pk6->geoCountry(country());
            pk6->geoRegion(subRegion());
        }

        if (pk6->htName() != otName())
        {
            pk6->htFriendship(pk6->baseFriendship());
            pk6->htAffection(0);
            pk6->htName(otName());
        }
        pk6->currentHandler(1);
        pk6->htGender(gender());

        if (pk6->htMemory() == 0)
        {
            pk6->htMemory(4);
            pk6->htTextVar(9);
            pk6->htIntensity(1);

            /*static constexpr u32 memoryBits[70] = { 
                0x000000, 0x04CBFD, 0x004BFD, 0x04CBFD, 0x04CBFD, 0xFFFBFB, 0x84FFF9, 0x47FFFF, 0xBF7FFA, 0x7660B0,
                0x80BDF9, 0x88FB7A, 0x083F79, 0x0001FE, 0xCFEFFF, 0x84EBAF, 0xB368B0, 0x091F7E, 0x0320A0, 0x080DDD,
                0x081A7B, 0x404030, 0x0FFFFF, 0x9A08BC, 0x089A7B, 0x0032AA, 0x80FF7A, 0x0FFFFF, 0x0805FD, 0x098278,
                0x0B3FFF, 0x8BBFFA, 0x8BBFFE, 0x81A97C, 0x8BB97C, 0x8BBF7F, 0x8BBF7F, 0x8BBF7F, 0x8BBF7F, 0xAC3ABE,
                0xBFFFFF, 0x8B837C, 0x848AFA, 0x88FFFE, 0x8B0B7C, 0xB76AB2, 0x8B1FFF, 0xBE7AB8, 0xB77EB8, 0x8C9FFD,
                0xBF9BFF, 0xF408B0, 0xBCFE7A, 0x8F3F72, 0x90DB7A, 0xBCEBFF, 0xBC5838, 0x9C3FFE, 0x9CFFFF, 0x96D83A,
                0xB770B0, 0x881F7A, 0x839F7A, 0x839F7A, 0x839F7A, 0x53897F, 0x41BB6F, 0x0C35FF, 0x8BBF7F, 0x8BBF7F 
            };*/

            u32 bits = 0x04CBFD; //memoryBits[pk6->htMemory()];
            while (true)
            {
                u32 feel = randomNumbers() % 20;
                if ((bits & (1 << feel)) != 0)
                {
                    pk6->htFeeling(feel);
                    break;
                }
            }
        }
    }
}
示例#24
0
/**
 * @brief Parses the Conquest .map map file in the path indicated to populate the instance
 */
void RiskMap::loadMap(const std::string& path) {
	std::ifstream infile(path);
	std::string line;
	int mode = 0;

	while (std::getline(infile, line))
	{
		std::string debug_str("Read line: ");
		debug_str.append(line);
		debug(debug_str);
		// Windows prefers /r/n, but getline() breaks only on \n.
		if (line.size() > 0 && line[line.size() - 1] == '\r') {
			line.resize(line.size() - 1);
		}

		// Set the mode for how we should process lines based on section headers
		if (line.compare("[Map]") == 0) {
			mode = MAP_PARSE_MODE_MAP;
			debug("  Parsing map metadata");
			continue;
		}
		if (line.compare("[Continents]") == 0) {
			mode = MAP_PARSE_MODE_CONTINENTS;
			debug("  Parsing continents");
			continue;
		}
		if (line.compare("[Territories]") == 0) {
			mode = MAP_PARSE_MODE_COUNTRIES;
			debug("  Parsing countries");
			continue;
		}

		// Process lines per the current mode.
		std::string item;
		std::stringstream line_stream(line);
		std::vector<std::string> values;
		if (mode == MAP_PARSE_MODE_MAP || line.length() == 0) {
			debug_str = "  Skipping: ";
			debug_str.append(line);
			debug(debug_str);
			continue;
		}
		else if (mode == MAP_PARSE_MODE_CONTINENTS) {
			while (std::getline(line_stream, item, '=')) {
				values.push_back(item);
			}
			debug_str = "  Adding continent: ";
			debug_str.append(values[0]);
			debug(debug_str);

			Continent continent(values[0]);
			continent.setReinforcementBonus(atoi(values[1].c_str()));
			this->addContinent(continent);
		}
		else if (mode == MAP_PARSE_MODE_COUNTRIES) {
			while (std::getline(line_stream, item, ',')) {
				values.push_back(item);
			}
			std::string continentName(values[3]);

			debug_str = "  Adding country: ";
			debug_str.append(values[0]);
			debug_str.append(" in continent ");
			debug_str.append(continentName);
			debug(debug_str);

			Country country(values[0]);
			country.setPositionX(atoi(values[1].c_str()));
			country.setPositionY(atoi(values[2].c_str()));
			country.setArmies(0);
			this->addCountry(country, continentName);
		}
		else {
			debug("Error parsing line: " + line);
			return;
		}
	}

	debug("Parsing file again to configure adjacencies");
	infile.clear();
	infile.seekg(0, std::ios_base::beg);
	while (std::getline(infile, line))
	{
		std::string debug_str("Read line: ");
		debug_str.append(line);
		debug(debug_str);
		// Windows prefers /r/n, but getline() breaks only on \n.
		if (line.size() > 0 && line[line.size() - 1] == '\r') {
			line.resize(line.size() - 1);
		}

		// Set the mode for how we should process lines based on section headers
		if (line.compare("[Map]") == 0) {
			mode = MAP_PARSE_MODE_MAP;
			debug("  Parsing map metadata");
			continue;
		}
		if (line.compare("[Continents]") == 0) {
			mode = MAP_PARSE_MODE_CONTINENTS;
			debug("  Parsing continents");
			continue;
		}
		if (line.compare("[Territories]") == 0) {
			mode = MAP_PARSE_MODE_COUNTRIES;
			debug("  Parsing countries");
			continue;
		}

		// Process lines per the current mode.
		std::string item;
		std::stringstream line_stream(line);
		std::vector<std::string> values;
		if (mode != MAP_PARSE_MODE_COUNTRIES || line.length() == 0) {
			debug_str = "  Skipping: ";
			debug_str.append(line);
			debug(debug_str);
			continue;
		}
		else if (mode == MAP_PARSE_MODE_COUNTRIES) {
			while (std::getline(line_stream, item, ',')) {
				values.push_back(item);
			}
			Country* country = this->getCountry(values[0]);
			std::vector<std::string>::iterator iter;
			for (iter = values.begin() + 4; iter < values.end(); iter++) {
				Country* neighbour = this->getCountry(*iter);
				this->addNeighbour(country->getName(), neighbour->getName());

				debug_str = "  ";
				debug_str.append(country->getName());
				debug_str.append(" touches ");
				debug_str.append(neighbour->getName());
				debug(debug_str);
			}
		}
		else {
			debug("Error parsing line: " + line);
			return;
		}
	}

	debug("Finished parsing: " + path);
}
示例#25
0
文件: klocale.cpp 项目: vasi/kdelibs
QString KLocale::country() const
{
    return d->country();
}
示例#26
0
void CVideoInfoTag::ParseNative(const TiXmlElement* movie, bool prioritise)
{
  std::string value;

  if (XMLUtils::GetString(movie, "title", value))
    SetTitle(value);

  if (XMLUtils::GetString(movie, "originaltitle", value))
    SetOriginalTitle(value);

  if (XMLUtils::GetString(movie, "showtitle", value))
    SetShowTitle(value);

  if (XMLUtils::GetString(movie, "sorttitle", value))
    SetSortTitle(value);

  XMLUtils::GetFloat(movie, "rating", m_fRating);
  XMLUtils::GetInt(movie, "userrating", m_iUserRating);
  XMLUtils::GetFloat(movie, "epbookmark", m_fEpBookmark);
  int max_value = 10;
  const TiXmlElement* rElement = movie->FirstChildElement("rating");
  if (rElement && (rElement->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value>=1)
  {
    m_fRating = m_fRating / max_value * 10; // Normalise the Movie Rating to between 1 and 10
  }
  const TiXmlElement* urElement = movie->FirstChildElement("userrating");
  if (urElement && (urElement->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value >= 1)
    m_iUserRating = m_iUserRating / max_value * 10; // Normalise the user Movie Rating to between 1 and 10
  XMLUtils::GetInt(movie, "year", m_iYear);
  XMLUtils::GetInt(movie, "top250", m_iTop250);
  XMLUtils::GetInt(movie, "season", m_iSeason);
  XMLUtils::GetInt(movie, "episode", m_iEpisode);
  XMLUtils::GetInt(movie, "track", m_iTrack);
  if (XMLUtils::GetString(movie, "uniqueid", value))
    SetUniqueId(value);

  XMLUtils::GetInt(movie, "displayseason", m_iSpecialSortSeason);
  XMLUtils::GetInt(movie, "displayepisode", m_iSpecialSortEpisode);
  std::string strFlag;
  XMLUtils::GetString(movie,"specialflag", strFlag);
  if (strFlag == "seasonfinale")
    m_iSpecialFlag = EPISODE_FLAG_SEASON_FINALE;
  else if (strFlag == "seriesfinale")
    m_iSpecialFlag = EPISODE_FLAG_SERIES_FINALE;
  else
    m_iSpecialFlag = EPISODE_FLAG_NONE;
  int after=0;
  XMLUtils::GetInt(movie, "displayafterseason",after);
  if (after > 0)
  {
    m_iSpecialSortSeason = after;
    m_iSpecialSortEpisode = 0x1000; // should be more than any realistic episode number
  }
  if (XMLUtils::GetString(movie, "votes", value))
    SetVotes(value);

  if (XMLUtils::GetString(movie, "outline", value))
    SetPlotOutline(value);

  if (XMLUtils::GetString(movie, "plot", value))
    SetPlot(value);

  if (XMLUtils::GetString(movie, "tagline", value))
    SetTagLine(value);

  
  if (XMLUtils::GetString(movie, "runtime", value) && !value.empty())
    m_duration = GetDurationFromMinuteString(StringUtils::Trim(value));
  
  if (XMLUtils::GetString(movie, "mpaa", value))
    SetMPAARating(value);

  XMLUtils::GetInt(movie, "playcount", m_playCount);
  XMLUtils::GetDate(movie, "lastplayed", m_lastPlayed);
  
  if (XMLUtils::GetString(movie, "file", value))
    SetFile(value);

  if (XMLUtils::GetString(movie, "path", value))
    SetPath(value);

  if (XMLUtils::GetString(movie, "id", value))
    SetIMDBNumber(value);

  if (XMLUtils::GetString(movie, "filenameandpath", value))
    SetFileNameAndPath(value);

  XMLUtils::GetDate(movie, "premiered", m_premiered);
  
  if (XMLUtils::GetString(movie, "status", value))
    SetStatus(value);

  if (XMLUtils::GetString(movie, "code", value))
    SetProductionCode(value);

  XMLUtils::GetDate(movie, "aired", m_firstAired);
  
  if (XMLUtils::GetString(movie, "album", value))
    SetAlbum(value);

  if (XMLUtils::GetString(movie, "trailer", value))
    SetTrailer(value);

  if (XMLUtils::GetString(movie, "basepath", value))
    SetBasePath(value);

  size_t iThumbCount = m_strPictureURL.m_url.size();
  std::string xmlAdd = m_strPictureURL.m_xml;

  const TiXmlElement* thumb = movie->FirstChildElement("thumb");
  while (thumb)
  {
    m_strPictureURL.ParseElement(thumb);
    if (prioritise)
    {
      std::string temp;
      temp << *thumb;
      xmlAdd = temp+xmlAdd;
    }
    thumb = thumb->NextSiblingElement("thumb");
  }

  // prioritise thumbs from nfos
  if (prioritise && iThumbCount && iThumbCount != m_strPictureURL.m_url.size())
  {
    rotate(m_strPictureURL.m_url.begin(),
           m_strPictureURL.m_url.begin()+iThumbCount, 
           m_strPictureURL.m_url.end());
    m_strPictureURL.m_xml = xmlAdd;
  }

  std::vector<std::string> genres(m_genre);
  if (XMLUtils::GetStringArray(movie, "genre", genres, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetGenre(genres);

  std::vector<std::string> country(m_country);
  if (XMLUtils::GetStringArray(movie, "country", country, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetCountry(country);

  std::vector<std::string> credits(m_writingCredits);
  if (XMLUtils::GetStringArray(movie, "credits", credits, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetWritingCredits(credits);

  std::vector<std::string> director(m_director);
  if (XMLUtils::GetStringArray(movie, "director", director, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetDirector(director);

  std::vector<std::string> showLink(m_showLink);
  if (XMLUtils::GetStringArray(movie, "showlink", showLink, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetShowLink(showLink);

  // cast
  const TiXmlElement* node = movie->FirstChildElement("actor");
  if (node && node->FirstChild() && prioritise)
    m_cast.clear();
  while (node)
  {
    const TiXmlNode *actor = node->FirstChild("name");
    if (actor && actor->FirstChild())
    {
      SActorInfo info;
      info.strName = actor->FirstChild()->Value();
      
      if (XMLUtils::GetString(node, "role", value))
        info.strRole = StringUtils::Trim(value);
      
      XMLUtils::GetInt(node, "order", info.order);
      const TiXmlElement* thumb = node->FirstChildElement("thumb");
      while (thumb)
      {
        info.thumbUrl.ParseElement(thumb);
        thumb = thumb->NextSiblingElement("thumb");
      }
      const char* clear=node->Attribute("clear");
      if (clear && stricmp(clear,"true"))
        m_cast.clear();
      m_cast.push_back(info);
    }
    node = node->NextSiblingElement("actor");
  }

  if (XMLUtils::GetString(movie, "set", value))
    SetSet(value);

  std::vector<std::string> tags(m_tags);
  if (XMLUtils::GetStringArray(movie, "tag", tags, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetTags(tags);

  std::vector<std::string> studio(m_studio);
  if (XMLUtils::GetStringArray(movie, "studio", studio, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetStudio(studio);

  // artists
  std::vector<std::string> artist(m_artist);
  node = movie->FirstChildElement("artist");
  if (node && node->FirstChild() && prioritise)
    artist.clear();
  while (node)
  {
    const TiXmlNode* pNode = node->FirstChild("name");
    const char* pValue=NULL;
    if (pNode && pNode->FirstChild())
      pValue = pNode->FirstChild()->Value();
    else if (node->FirstChild())
      pValue = node->FirstChild()->Value();
    if (pValue)
    {
      const char* clear=node->Attribute("clear");
      if (clear && stricmp(clear,"true")==0)
        artist.clear();
      std::vector<std::string> newArtists = StringUtils::Split(pValue, g_advancedSettings.m_videoItemSeparator);
      artist.insert(artist.end(), newArtists.begin(), newArtists.end());
    }
    node = node->NextSiblingElement("artist");
  }
  SetArtist(artist);

  node = movie->FirstChildElement("fileinfo");
  if (node)
  {
    // Try to pull from fileinfo/streamdetails/[video|audio|subtitle]
    const TiXmlNode *nodeStreamDetails = node->FirstChild("streamdetails");
    if (nodeStreamDetails)
    {
      const TiXmlNode *nodeDetail = NULL;
      while ((nodeDetail = nodeStreamDetails->IterateChildren("audio", nodeDetail)))
      {
        CStreamDetailAudio *p = new CStreamDetailAudio();
        if (XMLUtils::GetString(nodeDetail, "codec", value))
          p->m_strCodec = StringUtils::Trim(value);

        if (XMLUtils::GetString(nodeDetail, "language", value))
          p->m_strLanguage = StringUtils::Trim(value);

        XMLUtils::GetInt(nodeDetail, "channels", p->m_iChannels);
        StringUtils::ToLower(p->m_strCodec);
        StringUtils::ToLower(p->m_strLanguage);
        m_streamDetails.AddStream(p);
      }
      nodeDetail = NULL;
      while ((nodeDetail = nodeStreamDetails->IterateChildren("video", nodeDetail)))
      {
        CStreamDetailVideo *p = new CStreamDetailVideo();
        if (XMLUtils::GetString(nodeDetail, "codec", value))
          p->m_strCodec = StringUtils::Trim(value);

        XMLUtils::GetFloat(nodeDetail, "aspect", p->m_fAspect);
        XMLUtils::GetInt(nodeDetail, "width", p->m_iWidth);
        XMLUtils::GetInt(nodeDetail, "height", p->m_iHeight);
        XMLUtils::GetInt(nodeDetail, "durationinseconds", p->m_iDuration);
        if (XMLUtils::GetString(nodeDetail, "stereomode", value))
          p->m_strStereoMode = StringUtils::Trim(value);

        StringUtils::ToLower(p->m_strCodec);
        StringUtils::ToLower(p->m_strStereoMode);
        m_streamDetails.AddStream(p);
      }
      nodeDetail = NULL;
      while ((nodeDetail = nodeStreamDetails->IterateChildren("subtitle", nodeDetail)))
      {
        CStreamDetailSubtitle *p = new CStreamDetailSubtitle();
        if (XMLUtils::GetString(nodeDetail, "language", value))
          p->m_strLanguage = StringUtils::Trim(value);
        StringUtils::ToLower(p->m_strLanguage);
        m_streamDetails.AddStream(p);
      }
    }
    m_streamDetails.DetermineBestStreams();
  }  /* if fileinfo */

  const TiXmlElement *epguide = movie->FirstChildElement("episodeguide");
  if (epguide)
  {
    // DEPRECIATE ME - support for old XML-encoded <episodeguide> blocks.
    if (epguide->FirstChild() && strnicmp("<episodeguide", epguide->FirstChild()->Value(), 13) == 0)
      m_strEpisodeGuide = epguide->FirstChild()->Value();
    else
    {
      std::stringstream stream;
      stream << *epguide;
      m_strEpisodeGuide = stream.str();
    }
  }

  // fanart
  const TiXmlElement *fanart = movie->FirstChildElement("fanart");
  if (fanart)
  {
    // we prioritise mixed-mode nfo's with fanart set
    if (prioritise)
    {
      std::string temp;
      temp << *fanart;
      m_fanart.m_xml = temp+m_fanart.m_xml;
    }
    else
      m_fanart.m_xml << *fanart;
    m_fanart.Unpack();
  }

  // resumePoint
  const TiXmlNode *resume = movie->FirstChild("resume");
  if (resume)
  {
    XMLUtils::GetDouble(resume, "position", m_resumePoint.timeInSeconds);
    XMLUtils::GetDouble(resume, "total", m_resumePoint.totalTimeInSeconds);
  }

  XMLUtils::GetDateTime(movie, "dateadded", m_dateAdded);
}
示例#27
0
bool PhysicalLocation::operator==(const PhysicalLocation& o) const
{
	return country() == o.country() && region() == o.region() && locality() == o.locality() && area() == o.area() && street() == o.street() && building() == o.building() && floor() == o.floor() && room() == o.room() && postalcode() == o.postalcode() && text() == o.text();

}
示例#28
0
QString GeoLocation::translatedProvince() const {
    return Province.isEmpty() ? QString() : i18nc(QString("Region/state in " + country()).toUtf8().data(), Province.toUtf8().data());
}