Ejemplo n.º 1
0
void CloudSyncManager::setOwncloudCredentials( const QString &server, const QString &user, const QString &password )
{
    QUrl const oldApiUrl = apiUrl();
    blockSignals( true );
    setOwncloudServer( server );
    setOwncloudUsername( user );
    setOwncloudPassword( password );
    blockSignals( false );
    if ( oldApiUrl != apiUrl() ) {
        emit apiUrlChanged( apiUrl() );
    }
}
Ejemplo n.º 2
0
void FoursquareModel::getAdditionalItems( const GeoDataLatLonAltBox& box, qint32 number )
{
    if( marbleModel()->planetId() != "earth" ) {
        return;
    }
    
    QString clientId = "YPRWSYFW1RVL4PJQ2XS5G14RTOGTHOKZVHC1EP5KCCCYQPZF";
    QString clientSecret = "5L2JDCAYQCEJWY5FNDU4A1RWATE4E5FIIXXRM41YBTFSERUH";
    
    QString apiUrl( "https://api.foursquare.com/v2/venues/search" );
    qreal const distanceLon = marbleModel()->planetRadius() * distanceSphere( box.west(), box.north(), box.east(), box.north() );
    qreal const distanceLat = marbleModel()->planetRadius() * distanceSphere( box.west(), box.north(), box.west(), box.south() );
    qreal const area = distanceLon * distanceLat;
    if ( area > 10 * 1000 * KM2METER * KM2METER ) {
        // Large area (> 10.000 km^2) => too large for bbox queries
        apiUrl += "?ll=" + QString::number( box.center().latitude(Marble::GeoDataCoordinates::Degree) );
        apiUrl += ',' + QString::number( box.center().longitude(Marble::GeoDataCoordinates::Degree) );
        apiUrl += "&intent=checkin";
    } else {
        apiUrl += "?ne=" + QString::number( box.north(Marble::GeoDataCoordinates::Degree) );
        apiUrl += ',' + QString::number( box.east(Marble::GeoDataCoordinates::Degree) );
        apiUrl += "&sw=" + QString::number( box.south(Marble::GeoDataCoordinates::Degree) );
        apiUrl += ',' + QString::number( box.west(Marble::GeoDataCoordinates::Degree) );
        apiUrl += "&intent=browse";
    }
    apiUrl += "&limit=" + QString::number( number );
    apiUrl += "&client_id=" + clientId;
    apiUrl += "&client_secret=" + clientSecret;
    apiUrl += "&v=20120601";
    downloadDescriptionFile( QUrl( apiUrl ) );
}
Ejemplo n.º 3
0
void Connection::save(QVariantMap& m) const
{
    m["title"] = title();
    m["apiUrl"] = apiUrl();
    m["userEmail"] = userEmail();
    m["apiKey"] = apiKey();
}
Ejemplo n.º 4
0
void CloudSyncManager::setOwncloudPassword( const QString &password )
{
    if ( d->m_owncloudPassword != password ) {
        d->m_owncloudPassword = password;
        emit owncloudPasswordChanged( d->m_owncloudPassword );
        emit apiUrlChanged( apiUrl() );
    }
}
Ejemplo n.º 5
0
void CloudSyncManager::setOwncloudUsername( const QString &username )
{
    if ( d->m_owncloudUsername != username ) {
        d->m_owncloudUsername = username;
        emit owncloudUsernameChanged( d->m_owncloudUsername );
        emit apiUrlChanged( apiUrl() );
    }
}
Ejemplo n.º 6
0
void CloudSyncManager::setOwncloudServer( const QString &server )
{
    if ( d->m_ownloudServer != server ) {
        d->m_ownloudServer = server;
        emit owncloudServerChanged( d->m_ownloudServer );
        emit apiUrlChanged( apiUrl() );
    }
}
Ejemplo n.º 7
0
/*!
 * 	Start upload process
 */
void Uploader_MediaCrush::startUploading()
{	
    createData();
	createRequest(imageData, apiUrl());

   _request.setRawHeader("Host", _host);
    Uploader::startUploading();
}
Ejemplo n.º 8
0
void CloudSyncManager::setOwncloudServer( const QString &server )
{
    QString const oldProtocol = d->m_owncloudProtocol;
    QString const oldServer = d->m_ownloudServer;

    if ( server.startsWith( "http://" ) ) {
        d->m_owncloudProtocol = "http://";
        d->m_ownloudServer = server.mid( 7 );
    } else if ( server.startsWith( "https://" ) ) {
        d->m_owncloudProtocol = "https://";
        d->m_ownloudServer = server.mid ( 8 );
    } else {
        d->m_owncloudProtocol = "http://";
        d->m_ownloudServer = server;
    }

    if ( oldServer != d->m_ownloudServer ) {
        emit owncloudServerChanged( owncloudServer() );
        emit apiUrlChanged( apiUrl() );
    } else if ( oldProtocol != d->m_owncloudProtocol ) {
        emit apiUrlChanged( apiUrl() );
    }
}
Ejemplo n.º 9
0
void SwfToHtml5::process()
{
    m_filesLstWgt->clear();
    m_filesLstWgt->addItems(m_pathToFiles);
    m_pBeginConvertBtn->setEnabled(false);
    m_pLoadFileBtn->setEnabled(false);
    m_pLoadFileBtn->setText("Convertation started!");
    if (m_pathToFiles.size() < 1)
        return;

    for (int i = 0; i < m_pathToFiles.size(); ++i) {
        if (QFileInfo(m_pathToFiles.at(i)).isFile()) {
            QFile inputFile(m_pathToFiles.at(i));
            QByteArray bufBa;
            m_nameOfFile = m_pathToFiles.at(i);
            m_nameOfFile = m_nameOfFile.remove(".swf");
            m_nameOfFile += ".html";
            //read swf file
            if (!inputFile.open(QIODevice::ReadOnly)) {
                qDebug()<<"Could not open the input file\n"<<m_pathToFiles.at(i);
                return;
            } else {
                while(!inputFile.atEnd()) {
                    bufBa += inputFile.readLine();
                }
            }
            bufBa = bufBa.toBase64();
            bufBa = bufBa.replace('+', '-');
            bufBa = bufBa.replace('/', '_');

            QUrl apiUrl("https://www.googleapis.com/rpc?key=AIzaSyCC_WIu0oVvLtQGzv4-g7oaWNoc-u8JpEI");
            QByteArray req = "{ \"apiVersion\": \"v1\",\"method\": \"swiffy.convertToHtml\", \"params\": { \"client\": \"Swiffy Flash Extension\", \"input\": \"$\" } }";
            req = req.replace('$', bufBa);

            QNetworkRequest request(apiUrl);

            QEventLoop eventLoop;

            request.setHeader(QNetworkRequest::ContentTypeHeader, "www.googleapis.com");

            QNetworkAccessManager *manager = new QNetworkAccessManager(this);

            connect(manager, &QNetworkAccessManager::finished, &eventLoop, &QEventLoop::quit);

            QNetworkReply *reply = manager->post(request, req);
            eventLoop.exec();

            QString dataFromReply;
            if (reply->error() == QNetworkReply::NoError) {
                dataFromReply = QString::fromUtf8(reply->readAll());
            }
            QByteArray replyBa;
            replyBa.append(dataFromReply);

            QFile replyFile("json.txt");
            replyFile.open(QIODevice::WriteOnly);
            replyFile.write(replyBa);
            replyFile.close();

            QFile jsonFile("json.txt");
            if (jsonFile.open(QIODevice::ReadOnly)) {
                QJsonParseError parseError;
                QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonFile.readAll(), &parseError);
                if (parseError.error == QJsonParseError::NoError) {
                    if(jsonDoc.isObject())
                        parseJSON(jsonDoc.object());
                }
                else
                    qDebug() << "JSON parse error: " << parseError.errorString();
            }
            else
                qDebug() << "json.txt not open";
            reply->deleteLater();
        }
        ++cnt;
    }
    cnt = 0;
    m_pLoadFileBtn->setText("Load files");
    m_pLoadFileBtn->setEnabled(true);
    m_filesLstWgt->addItem("Finished!");
    m_pBeginConvertBtn->setEnabled(true);
}
Ejemplo n.º 10
0
///
/// Returns a copy of the settings with a new URL to the API.
///
Settings Settings::withApiUrl(const std::string &apiUrl) const {
	auto copy = *this;
	copy.apiUrl(apiUrl);
	return copy;
}
Ejemplo n.º 11
0
KUrl LaconicaAccount::homepageUrl() const
{
    return apiUrl().upUrl();
}
Ejemplo n.º 12
0
void Connection::updateValidFlag()
{
    setValid(!apiUrl().isEmpty() && !apiKey().isEmpty());
}
Ejemplo n.º 13
0
// Private methods
//--------------------------------------------------------------------
int ArmoryImporter::readJSONValues(ImportType type, std::string url, wxJSONValue & result) const
{
  wxString apiPage;
  switch(type)
  {
    case CHARACTER:
    {
      /*
				Blizzard's API is mostly RESTful, with data being returned as JSON arrays.
				Full documentation available here: http://blizzard.github.com/api-wow-docs/

				We can now gather all the data with a single request of Host + "/api/wow/character/" + Realm + "/" + CharacterName + "?fields=appearance,items"
				Example: http://us.battle.net/api/wow/character/steamwheedle-cartel/Kjasi?fields=appearance,items

				This will give us all the information we need inside of a JSON array.
				Format as follows:
				{
					"lastModified":1319438058000
					"name":"Kjasi",
					"realm":"Steamwheedle Cartel",
					"class":5,
					"race":1,
					"gender":0,
					"level":83,
					"achievementPoints":4290,
					"thumbnail":"steamwheedle-cartel/193/3589057-avatar.jpg",
					"items":{	This is the Items array. All available item information is listed here.
						"averageItemLevel":298,
						"averageItemLevelEquipped":277,
						"head":{
							"id":50006,
							"name":"Corp'rethar Ceremonial Crown",
							"icon":"inv_helmet_156",
							"quality":4,
							"tooltipParams":{
								"gem0":41376,
								"gem1":40151,
								"enchant":3819,
								"reforge":119
								"transmogItem":63672
							}
						},
						(More slots),
						"ranged":{
							"id":55480,
							"name":"Swamplight Wand of the Invoker",
							"icon":"inv_wand_1h_cataclysm_b_01",
							"quality":2,
							"tooltipParams":{
								"suffix":-39
							}
						}
					},
					"appearance":{
						"faceVariation":11,
						"skinColor":1,
						"hairVariation":11,
						"hairColor":4,
						"featureVariation":1,
						"showHelm":true,
						"showCloak":true
					}
				}

				As you can see, this will give us almost all the data we need to properly rebuild the character.

       */
      wxString strURL(url);

      // Import from http://us.battle.net/wow/en/character/steamwheedle-cartel/Kjasi/simple
      if ((strURL.Find(wxT("simple")) == wxNOT_FOUND) &&
          (strURL.Find(wxT("advanced")) == wxNOT_FOUND))
      {
        // due to Qt plugin, this cause application crash
        // temporary solution : cascade return value to main app to display the pop up (see modelviewer.cpp)
        //wxMessageBox(wxT("Improperly Formatted URL.\nMake sure your link ends in /simple or /advanced."),wxT("Bad Armory Link"));
        LOG_INFO << wxT("Improperly Formatted URL. Lacks /simple and /advanced");
        return 2;
      }
      wxString strDomain = strURL.Mid(7).BeforeFirst('/');
      wxString strPage = strURL.Mid(7).Mid(strDomain.Len());

      wxString Region = strDomain.BeforeFirst('.');

      wxString strp = strPage.BeforeLast('/');	// No simple/advanced
      wxString CharName = strp.AfterLast('/');
      strp = strp.BeforeLast('/');				// Update strp
      wxString Realm = strp.AfterLast('/');

      LOG_INFO << "Loading Battle.Net Armory. Region: " << Region << ", Realm: " << Realm.c_str() << ", Character: " << CharName.c_str();

      apiPage = wxT("https://wowmodelviewer.net/armory.php?region=");
      apiPage << Region << "&realm=" << Realm << "&char=" << CharName;
      break;
    }
    case ITEM:
    {
      // url given is something like http://eu.battle.net/wow/fr/item/104673
      // we need :
      // 1. base battle.net address
      // 2. locale (fr in above example) - Later
      // 3. item number

      // for the sake of simplicity, only handle english name for now

      wxString strURL(url);
      wxString itemNumber = strURL.Mid(7).AfterLast('/');

      LOG_INFO << "Loading Battle.Net Armory. Item: " << itemNumber.c_str();

      apiPage = wxT("https://wowmodelviewer.net/armory.php?item=");
      apiPage << itemNumber;

      break;
    }
  }

  LOG_INFO << "Final API Page: " << apiPage.c_str();

  QNetworkAccessManager networkManager;
  QUrl apiUrl(apiPage.c_str());
  QNetworkRequest request(apiUrl);
  request.setRawHeader("User-Agent", "WoWModelViewer");
  QNetworkReply *reply = networkManager.get(request);

  QEventLoop loop;
  connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
  connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), &loop, SLOT(quit()));
  loop.exec();

  QByteArray bts = reply->readAll();

  LOG_INFO << __FUNCTION__ << bts;

  wxJSONReader reader;
  return reader.Parse(bts.data(),&result);
}