Exemplo n.º 1
0
inline void
WifiListWidget::Connect()
{
  if (!EnsureConnected()) {
    ShowMessageBox(_T("Network failure"), _("Connect"), MB_OK);
    return;
  }

  const unsigned i = GetList().GetCursorIndex();
  if (i >= networks.size())
    return;

  const auto &info = networks[i];
  if (info.id < 0) {
    const auto ssid = info.ssid;

    StaticString<256> caption;
    caption.Format(_("Passphrase of network '%s'"), ssid.c_str());

    StaticString<32> passphrase;
    passphrase.clear();
    if (info.security == OPEN_SECURITY)
      passphrase.clear();
    else if (!TextEntryDialog(passphrase, caption, false))
      return;

    if (!WifiConnect(info.security, wpa_supplicant, info.ssid, passphrase))
      ShowMessageBox(_T("Network failure"), _("Connect"), MB_OK);
  } else {
    if (!wpa_supplicant.RemoveNetwork(info.id) || !wpa_supplicant.SaveConfig())
      ShowMessageBox(_T("Error"), _("Remove"), MB_OK);
  }

  UpdateList();
}
Exemplo n.º 2
0
QUrl GoogleDriveService::GetStreamingUrlFromSongId(const QString& id) {
  EnsureConnected();
  QScopedPointer<google_drive::GetFileResponse> response(client_->GetFile(id));

  QEventLoop loop;
  connect(response.data(), SIGNAL(Finished()), &loop, SLOT(quit()));
  loop.exec();

  QUrl url(response->file().download_url());
  url.addQueryItem("access_token", client_->access_token());
  return url;
}
Exemplo n.º 3
0
QUrl SkydriveService::GetStreamingUrlFromSongId(const QString& file_id) {
  EnsureConnected();

  QUrl url(QString(kSkydriveBase) + file_id);
  QNetworkRequest request(url);
  AddAuthorizationHeader(&request);
  std::unique_ptr<QNetworkReply> reply(network_->get(request));
  WaitForSignal(reply.get(), SIGNAL(finished()));

  QJson::Parser parser;
  QVariantMap response = parser.parse(reply.get()).toMap();
  return response["source"].toUrl();
}
Exemplo n.º 4
0
void
WifiListWidget::OnAction(int id)
{
  switch (id) {
  case SCAN:
    if (EnsureConnected() && wpa_supplicant.Scan())
      UpdateList();
    break;

  case CONNECT:
    Connect();
    break;
  }
}
Exemplo n.º 5
0
void
WifiListWidget::UpdateList()
{
  status.Clear();

  if (EnsureConnected()) {
    wpa_supplicant.Status(status);

    for (auto &i : networks)
      i.old_visible = i.old_configured = true;

    UpdateScanResults();
    UpdateConfigured();

    /* remove items that are still marked as "old" */
    SweepList();
  } else
    networks.clear();

  GetList().SetLength(networks.size());

  UpdateButtons();
}
// ---------------------------------------------------------------------------
// Sends blind message to lockapp if the session is connected.
// ---------------------------------------------------------------------------
TInt RLockAccessExtension::SendMessage( TInt aMessage, TInt aParam1, TInt aParam2 )
{
    RDEBUG("0", 0);
    TInt ret = EnsureConnected( );
    RDEBUG("ret", ret);
    if ( ret == KErrNone )
    {
        // assign parameters to IPC argument
        // TIpcArgs args( aParam1, aParam2);
        // this is the old methd. Now we use QtHighway
        // ret = SendReceive( aMessage, args );
        RDEBUG("aMessage", aMessage);
        RDEBUG("aParam1", aParam1);
        RDEBUG("aParam2", aParam2);


        {   // old method. Not used any more. Kept as reference
            /*
            XQServiceRequest* mServiceRequest;
            RDEBUG("XQServiceRequest", 0);
            mServiceRequest = new XQServiceRequest("com.nokia.services.Autolock.Autolock","service(QString,QString,QString)");// use   , false    to make async
            RDEBUG("aMessage", 0);
            QString label;
            label = "" + QString("%1").arg(aMessage);
            *mServiceRequest << QString(label);
            RDEBUG("aParam1", 0);
            label = "" + QString("%1").arg(aParam1);
            *mServiceRequest << QString(label);
            RDEBUG("aParam2", 0);
            label = "" + QString("%1").arg(aParam2);
            *mServiceRequest << QString(label);
            int returnvalue;
            RDEBUG("send", 0);
            bool ret = mServiceRequest->send(returnvalue);
            RDEBUG("ret", ret);
            RDEBUG("returnvalue", returnvalue);
            */
        }

        RDEBUG("args", 0);
        QList<QVariant> args;
        args << QVariant(QString(QString::number(aMessage)));
        args << QVariant(QString(QString::number(aParam1)));
        args << QVariant(QString(QString::number(aParam2)));

        XQApplicationManager mAppManager;
        XQAiwRequest *request;
        RDEBUG("create", 0);
        request = mAppManager.create("com.nokia.services.Autolock", "Autolock", "service(QString,QString,QString)", false);
        // also works with		create("Autolock", "service(QString,QString,QString)", false);
        if(request)
        {
            RDEBUG("got request", 0);
        }
        else
        {
            RDEBUG("not got request", 0);
            RDebug::Printf( "%s %s (%u) not got request=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
            return KErrAbort;
        }

        RDEBUG("setArguments", 0);
        request->setArguments(args);
        RDEBUG("args", 0);
        int returnvalue=0;
        QVariant var = QVariant(returnvalue);
        RDEBUG("send", 0);
        bool retSend = request->send(var);
        returnvalue = var.toInt();
        RDEBUG("retSend", retSend);
        RDEBUG("returnvalue", returnvalue);
        int error = request->lastError();
        RDEBUG("error", error);
        ret = returnvalue;

        delete request;
    }
    RDEBUG("ret", ret);
    return ret;
}