bool ActionMail::Execute()
{
    IPCam *camera = NULL;

    if (mail_attachment != "")
        camera = dynamic_cast<IPCam *>(ListeRoom::Instance().get_io(mail_attachment));

    if (camera)
    {
        cInfoDom("rule.action.mail") <<  "Need to download camera ("
                                      << camera->get_param("name")
                                      << ") attachment";

        std::string tmpFile;
        int cpt = 0;

        //Get a temporary filename
        do
        {
            tmpFile = "/tmp/calaos_mail_attachment_";
            tmpFile += Utils::to_string(cpt);
            cpt++;
        }
        while (ecore_file_exists(tmpFile.c_str()));

        // Autodestroy file downloader
        cDebug() << "DL URL: " << camera->getPictureUrl();
        FileDownloader* downloader = new FileDownloader(camera->getPictureUrl(), tmpFile, true);
        downloader->addCallback([=](std::string signal, void *sender_data)
        {
            if (signal == "done")
            {
                mail_attachment_tfile = *(reinterpret_cast<std::string *>(sender_data));
                sendMail();
            }
            else if (signal == "failed" || signal == "aborted")
            {
                mail_attachment_tfile.clear();
                sendMail();
            }
        });
        downloader->Start();
    }
    else
    {
        sendMail();

        cInfoDom("rule.action.mail") <<  "Ok, mail is in queue";
    }

    return true;
}
Esempio n. 2
0
void ActivityWebView::buttonCallback(void *data, Evas_Object *edje_object, string emission, string source)
{
    if (source == "button.back")
        elm_web_back(web);
    else if (source == "button.forward")
        elm_web_forward(web);
    else if (source == "button.reload")
        elm_web_reload_full(web);
    else if (source == "button.stop")
        elm_web_stop(web);
    else if (source == "button.forward")
        elm_web_forward(web);
    else if (source == "button.home")
        goToCallback(DEFAULT_BROWSER_URL);
    else if (source == "button.go")
    {
        ApplicationMain::Instance().ShowKeyboard("Entrez une URL ci-dessous",
                                                 sigc::mem_fun(*this, &ActivityWebView::goToCallback),
                                                 false,
                                                 elm_web_uri_get(web));
    }
    else if (source == "button.bookmark")
    {
        string url = elm_web_uri_get(web);

        string _url = DEFAULT_BROWSER_URL;
        _url += "Bookmark.php?new=" + url_encode(url);
        _url += "&title=" + url_encode(elm_web_title_get(web));
        _url += "&thumb_file=/tmp/thumb.png";

        setDragValue("progress.level", 0.0, 0.0);
        setPartText("progress.text", "Saving...");
        EmitSignal("saving,bookmark", "calaos");

        FileDownloader *fdownloader = new FileDownloader(_url, "/dev/null", true);
        fdownloader->Start();
    }
}
Esempio n. 3
0
void Calaos::CallUrl(string url, string post_data)
{
    FileDownloader *downloader = new FileDownloader(url, post_data, "text/plain", true);
    downloader->Start();
}