示例#1
0
bool Utils::file_copy(std::string source, std::string dest)
{
    FILE *f1, *f2;
    char buf[16384];
    char realpath1[PATH_MAX];
    char realpath2[PATH_MAX];
    size_t num;
    size_t res;

    if (!realpath(source.c_str(), realpath1)) return false;
    if (realpath(dest.c_str(), realpath2) && !strcmp(realpath1, realpath2)) return false;

    f1 = fopen(source.c_str(), "rb");
    if (!f1) return false;
    f2 = fopen(dest.c_str(), "wb");
    if (!f2)
    {
        fclose(f1);
        return false;
    }

    while ((num = fread(buf, 1, sizeof(buf), f1)) > 0)
    {
        res = fwrite(buf, 1, num, f2);
        if (res <= 0) cCritical() <<  "Failed to fwrite !";
    }

    fclose(f1);
    fclose(f2);

    return true;
}
示例#2
0
void MainContentView::showView(BaseView *view)
{
    cCritical() <<  "MainMenuView:showView() not implemented !";

    if (!view)
        throw(runtime_error("MainContentView::showView(): view is NULL !"));
}
EdjeObject *ActivityAudioListView::createRootButton(string title, string subtitle, string total, int row, int col)
{
    EdjeObject *obj = new EdjeObject(theme, evas);
    obj->LoadEdje("calaos/audio/browser/button");
    obj->setPartText("title", title);
    obj->setPartText("subtitle", subtitle);
    obj->setPartText("total", total);
    obj->Show();

    int w, h;
    edje_object_size_min_get(obj->getEvasObject(), &w, &h);
    obj->Resize(w, h);
    evas_object_size_hint_min_set(obj->getEvasObject(), w, h);

    browser_root_buttons.push_back(obj);

    if (!edje_object_part_table_pack(browser_root->getEvasObject(), "table", obj->getEvasObject(),
                                     col, row, 1, 1))
        cCritical() <<  "ActivityAudioListView::createRootButton(), failed to pack object into table !";

    return obj;
}
ApplicationController::ApplicationController(Evas *_e, Evas_Object *_l):
    evas(_e),
    layout(_l),
    mouseCursor(NULL),
    menu_hidden(false),
    homeController(NULL),
    mediaController(NULL),
    scenariosController(NULL),
    configController(NULL),
    keyboardController(NULL),
    webController(NULL),
    editScController(NULL),
    scheduleScController(NULL)
{
    if (Utils::get_config_option("show_cursor") == "true")
    {
        mouseCursor = new EdjeObject(ApplicationMain::getTheme(), evas);

        try
        {
            mouseCursor->LoadEdje("calaos/cursor");
        }
        catch(exception const& e)
        {
            cCritical() <<  "ApplicationController: Can't load mouse cursor";
            throw;
        }

        int w, h;
        edje_object_size_min_get(mouseCursor->getEvasObject(), &w, &h);
        mouseCursor->Resize(w, h);
        mouseCursor->Show();

        ecore_evas_object_cursor_set(ecore_evas_ecore_evas_get(evas), mouseCursor->getEvasObject(), EVAS_LAYER_MAX - 32, w / 2, h / 2);
    }
    else
    {
        Evas_Object *cursor = evas_object_rectangle_add(evas);
        evas_object_color_set(cursor, 0, 0, 0, 0);
        evas_object_resize(cursor, 1, 1);
        evas_object_show(cursor);

        ecore_evas_object_cursor_set(ecore_evas_ecore_evas_get(evas), cursor, EVAS_LAYER_MAX - 32, 0, 0);
    }

    menuView = new MainMenuView(evas, layout);

    menuView->setVersionString(PACKAGE_VERSION);

    menuView->on_home_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuHomeClick));
    menuView->on_media_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuMediaClick));
    menuView->on_scenario_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuScenarioClick));
    menuView->on_config_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuConfigClick));

    menuView->on_reboot_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuRebootClick));
    menuView->on_suspend_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuSuspendClick));
    menuView->on_widget_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuWidgetClick));
    menuView->on_addwidget_click.connect(sigc::mem_fun(*this, &ApplicationController::onMenuAddWidgetClick));

    //Start the model instance
    CalaosModel::Instance().home_loaded.connect(sigc::mem_fun(*this, &ApplicationController::home_loaded));
    CalaosModel::Instance().login_failed.connect(sigc::mem_fun(*this, &ApplicationController::login_failed));

    contentView = new MainContentView(evas, layout);
    elm_object_part_content_set(layout, "calaos.main.content", contentView->getSmartObject());

    widgetsController = new ActivityWidgetsController(evas, layout);

    contentView->addView(widgetsController->getView());

    menuView->on_menu_open.connect(sigc::mem_fun(*widgetsController, &ActivityWidgetsController::dimView));
    menuView->on_menu_close.connect(sigc::mem_fun(*widgetsController, &ActivityWidgetsController::resetView));
    menuView->on_widget_valid_click.connect(sigc::mem_fun(*widgetsController, &ActivityWidgetsController::validEdit));
    menuView->on_widget_cancel_click.connect(sigc::mem_fun(*widgetsController, &ActivityWidgetsController::cancelEdit));
}
示例#5
0
ApplicationMain::ApplicationMain(int argc, char **argv)
{
    cInfo() <<  "Calaos Home, starting...";

    if (system("killall -9 eskiss 2> /dev/null") == -1)
        cCritical() <<  "Error forking !";

    //init random generator
    srand(time(NULL));

    //Init SSL and CURL
    SSL_load_error_strings();
    SSL_library_init();
    curl_global_init(CURL_GLOBAL_ALL);

    char *themefile = argvOptionParam(argv, argv + argc, "--theme");
    if (themefile)
    {
        ApplicationMain::theme = themefile;
        cInfo() <<  "Using specified theme file: " << ApplicationMain::getTheme();
    }
    else
    {
        ApplicationMain::theme = Prefix::Instance().dataDirectoryGet() + "/default.edj";
        if (ecore_file_exists(ApplicationMain::theme.c_str()))
            cInfo() << "Using theme file " << theme;
        else
            cError() << theme << " Not found!";
    }

    //Init efl core
    if (!eina_init())
        throw (runtime_error("Unable to init Eina"));
    if (!ecore_init())
        throw (runtime_error("Unable to init Ecore"));
    if (!ecore_con_init())
        throw (runtime_error("Unable to init Ecore-Con"));
    if (!ecore_con_url_init())
        throw (runtime_error("Unable to init Ecore-Con-Url"));
    if (!evas_init())
        throw (runtime_error("Unable to init Evas"));
    if (!ecore_evas_init())
        throw (runtime_error("Unable to init Ecore-Evas"));
    if (!edje_init())
        throw (runtime_error("Unable to init Edje"));

    edje_frametime_set(1.0 / 60.0);
    edje_scale_set(1.0);

    if (!elm_init(argc, argv))
        throw (runtime_error("Unable to init Elementary"));

    //Load Calaos specific ELM extensions
    elm_theme_extension_add(NULL, ApplicationMain::getTheme());

    //Create the main window
    window = elm_win_add(NULL, "calaos-home", ELM_WIN_BASIC);
    elm_win_title_set(window, "Calaos Home");
    elm_win_borderless_set(window, true);

    bool bFullscreen = argvOptionCheck(argv, argv + argc, "--fullscreen");
    elm_win_fullscreen_set(window, bFullscreen);

    //Automatically quit main loop when the window is closed
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
    elm_win_autodel_set(window, true);

    if (argvOptionCheck(argv, argv + argc, "--set-elm-config"))
    {
        //force setting the correct elementary options for touchscreen
        elm_config_finger_size_set(10);
        elm_config_scroll_bounce_enabled_set(true);
        elm_config_scroll_thumbscroll_enabled_set(true);
        elm_config_scroll_thumbscroll_threshold_set(24);
        elm_config_scroll_thumbscroll_momentum_threshold_set(100.0);
        elm_config_scroll_bounce_friction_set(0.5);
        elm_config_scroll_page_scroll_friction_set(0.5);
        elm_config_scroll_bring_in_scroll_friction_set(0.5);
        elm_config_scroll_zoom_friction_set(0.5);
        elm_config_scroll_thumbscroll_friction_set(1.0);
        elm_config_scroll_thumbscroll_border_friction_set(0.5);
        elm_config_scroll_thumbscroll_sensitivity_friction_set(0.25);
    }

    evas_object_event_callback_add(window, EVAS_CALLBACK_RESIZE, _window_resize_cb, this);
    evas = evas_object_evas_get(window);

    Evas_Object *bg = elm_bg_add(window);
    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(window, bg);
    evas_object_show(bg);
    evas_object_size_hint_min_set(bg, 200, 200);
    elm_bg_color_set(bg, 0, 0, 0);

    layout = elm_layout_add(window);
    if (!elm_layout_file_set(layout, ApplicationMain::getTheme(), EDJE_GROUP_MAIN_LAYOUT))
    {
        string e = "Unable to find group \"";
        e += EDJE_GROUP_MAIN_LAYOUT;
        e += "\" in theme \"";
        e += ApplicationMain::getTheme();
        e += "\"";
        throw (runtime_error(e));
    }

    //create the screen suspend object and put it on the canvas
    ScreenSuspendView *screen_suspend = new ScreenSuspendView(evas, window);
    screen_suspend->Show();
    screen_suspend->setAutoDelete(true);

    evas_object_size_hint_weight_set(layout, 1.0, 1.0);
    evas_object_show(layout);

    evas_object_resize(window, 1024, 768);
    evas_object_show(window);
    ecore_evas_focus_set(ecore_evas_ecore_evas_get(evas_object_evas_get(window)), true);

    Resize();

    try
    {
        controller = new ApplicationController(evas, layout);
    }
    catch(exception const& e)
    {
        cCritical() <<  "Can't create ApplicationController";
        throw;
    }
}