Ejemplo n.º 1
0
void FileTransferInstance::pauseResumeSend()
{
    if (!(state == tsProcessing || state == tsPaused))
        return;

    if (remotePaused)
        return;

    Core::getInstance()->pauseResumeFileSend(friendId, fileNum);
//    if (state == tsProcessing)
//        state = tsPaused;
//    else state = tsProcessing;

    emit stateUpdated();
}
Ejemplo n.º 2
0
void FileTransferInstance::acceptRecvRequest()
{
    QString path = Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(friendId));
    if (path.isEmpty()) path = Settings::getInstance().getGlobalAutoAcceptDir();
    if (!path.isEmpty())
    {
        QDir dir(path);
        path = dir.filePath(filename);
        QFileInfo info(path);
        if (info.exists()) // emulate chrome
        {
            QString name = info.baseName(), ext = info.completeSuffix();
            int i = 0;
            do
            {
                path = dir.filePath(name + QString(" (%1)").arg(++i) + "." + ext);
            }
            while (QFileInfo(path).exists());
        }
        qDebug() << "File: auto saving to" << path;
    }
    else
    {
        while (true)
        {
            path = QFileDialog::getSaveFileName(0, tr("Save a file","Title of the file saving dialog"), QDir::home().filePath(filename));
            if (path.isEmpty())
                return;
            else
            {
                if (isFileWritable(path))
                    break;
                else
                    QMessageBox::warning(0, tr("Location not writable","Title of permissions popup"), tr("You do not have permission to write that location. Choose another, or cancel the save dialog.", "text of permissions popup"));
            }
        }
    }

    savePath = path;

    Core::getInstance()->acceptFileRecvRequest(friendId, fileNum, path);
    state = tsProcessing;

    effStartTime = QDateTime::currentDateTime();

    emit stateUpdated();
}
Ejemplo n.º 3
0
void VListFolderUE::processCommand(int p_id, const QString &p_cmd)
{
    Q_UNUSED(p_id);

    init();

    QString folderPath = m_folderPath;
    if (folderPath.isEmpty()) {
        VDirectory *dir = g_mainWin->getDirectoryTree()->currentDirectory();
        folderPath = dir->fetchPath();
    }

    listFolder(folderPath, p_cmd);

    m_listWidget->updateGeometry();
    emit widgetUpdated();
    emit stateUpdated(State::Success);
}
Ejemplo n.º 4
0
void FileTransferInstance::pauseResumeSend()
{
    if (!(state == tsProcessing || state == tsPaused))
        return;

    if (remotePaused)
        return;

    Core::getInstance()->pauseResumeFileSend(friendId, fileNum);
//    if (state == tsProcessing)
//        state = tsPaused;
//    else state = tsProcessing;
    if (state == tsPaused)
    {
        effStartTime = QDateTime::currentDateTime();
        previousBytesSent = lastBytesSent;
    }

    emit stateUpdated();
}
Ejemplo n.º 5
0
void VListUE::processCommand(int p_id, const QString &p_cmd)
{
    Q_UNUSED(p_id);

    init();

    clear(-1);

    switch (p_id) {
    case ID::History:
        listHistory(p_cmd);
        break;

    default:
        break;
    }

    m_listWidget->updateGeometry();
    emit widgetUpdated();
    emit stateUpdated(State::Success);
}
Ejemplo n.º 6
0
void FileTransferInstance::onFileTransferFinished(ToxFile File)
{
    if (File.fileNum != fileNum || File.friendId != friendId || File.direction != direction)
            return;
    disconnect(Core::getInstance(),0,this,0);

    if (File.direction == ToxFile::RECEIVING)
    {
        QImage preview;
        QFile previewFile(File.filePath);
        if (previewFile.open(QIODevice::ReadOnly) && previewFile.size() <= MAX_PREVIEW_SIZE) // Don't preview big (>25MiB) images
        {
            if (preview.loadFromData(previewFile.readAll()))
            {
                pic = preview.scaledToHeight(50);
            }
            previewFile.close();
        }
    }

    state = tsFinished;

    emit stateUpdated();
}
Ejemplo n.º 7
0
void FileTransferInstance::cancelTransfer()
{
    Core::getInstance()->cancelFileSend(friendId, fileNum);
    state = tsCanceled;
    emit stateUpdated();
}
HueOutputLightRGB::HueOutputLightRGB(Params &p):
    OutputLightRGB(p)
{
    ioDoc->friendlyNameSet("HueOutputLightRGB");
    ioDoc->descriptionSet(_("RGB Light dimmer using a Philips Hue"));
    ioDoc->linkAdd("Meet Hue", _("http://www.meethue.com"));
    ioDoc->paramAdd("host", _("Hue bridge IP address"), IODoc::TYPE_STRING, true);
    ioDoc->paramAdd("api", _("API key return by Hue bridge when assciation has been made. Use Hue Wizard in calaos_installer to get this value automatically."), IODoc::TYPE_STRING, true);
    ioDoc->paramAdd("id_hue", _("Unique ID describing the Hue Light. This value is returned by the Hue Wizard."), IODoc::TYPE_STRING, true);

    m_host = get_param("host");
    m_api = get_param("api");
    m_idHue = get_param("id_hue");

    m_timer = new EcoreTimer(2.0,[=](){
        std::string url = "http://" + m_host + "/api/" + m_api + "/lights/" + m_idHue;
        UrlDownloader *dl = new UrlDownloader(url, true);
        dl->m_signalCompleteData.connect([&](Eina_Binbuf *downloadedData, int status)
    {
         if (status)
         {
              json_error_t error;
              const unsigned char* c = eina_binbuf_string_get(downloadedData);
              json_t *root = json_loads((const char*)eina_binbuf_string_get(downloadedData), 0, &error);
              if (!root)
              {
                   cErrorDom("hue") << "Json received malformed : " << error.source
                                    << " " << error.text << " (" << Utils::to_string(error.line) << " )";
                   return;
              }
              if (!json_is_object(root))
              {
                   cErrorDom("hue") << "Protocol changed ? date received : " << eina_binbuf_string_get(downloadedData);
                   return;
              }

              json_t *tstate = json_object_get(root, "state");
              if (!tstate || !json_is_object(tstate))
              {
                   cErrorDom("hue") << "Protocol changed ? date received : " << eina_binbuf_string_get(downloadedData);
                   return;
              }

              int sat, bri, hue;
              bool on, reachable;

              sat = json_integer_value(json_object_get(tstate, "sat"));
              bri = json_integer_value(json_object_get(tstate, "bri"));
              hue = json_integer_value(json_object_get(tstate, "hue"));
              on = jansson_bool_get(tstate, "on");
              reachable = jansson_bool_get(tstate, "reachable");

              cDebugDom("hue") << "State: " << on << " Hue : " << hue << " Bri: " << bri << " Hue : " << hue << "Data : " << c;

              if (reachable)
                   stateUpdated(ColorValue::fromHsl((int)(hue * 360.0 / 65535.0),
                                                    (int)(sat * 100.0 / 255.0),
                                                    (int)(bri * 100.0 / 255.0)), on);
              else
                   stateUpdated(ColorValue(0,0,0), reachable);

              json_decref(root);
         }
         else
         {
              stateUpdated(ColorValue(0,0,0), false);
         }
    });

        if (!dl->httpGet())
             delete dl;
         });
}
Ejemplo n.º 9
0
Archivo: main.cpp Proyecto: CCJY/coliru
 void update()
 {
     qDebug() << "update";
     emit stateUpdated();
 }