示例#1
0
文件: settings.c 项目: baloo79/uTox
static int config_parser(const char* section, const char* key, const char* value, void* config_v) {
    UTOX_SAVE *config = (UTOX_SAVE*) config_v;

    switch(get_section(section)) {
        case GENERAL_SECTION: {
            parse_general_section(config, key, value);
            break;
        }
        case INTERFACE_SECTION: {
            parse_interface_section(config, key, value);
            break;
        }
        case AV_SECTION: {
            parse_av_section(config, key, value);
            break;
        }
        case NOTIFICATIONS_SECTION: {
            parse_notifications_section(config, key, value);
            break;
        }
        case ADVANCED_SECTION: {
            parse_advanced_section(config, key, value);
            break;
        }
        case UNKNOWN_SECTION: {
            LOG_NOTE("Settings", "Unknown section in config file: %s", section);
            break;
        }
    }

    return 1;
}
示例#2
0
文件: video.c 项目: Matsu616/uTox
static bool video_device_init(void *handle) {
    // initialize video (will populate video_width and video_height)
    if (handle == (void *)1) {
        if (!native_video_init((void *)1)) {
            LOG_TRACE("uToxVideo", "native_video_init() failed for desktop" );
            return false;
        }
    } else {
        if (!handle || !native_video_init(*(void **)handle)) {
            LOG_TRACE("uToxVideo", "native_video_init() failed webcam" );
            return false;
        }
    }
    vpx_img_alloc(&input, VPX_IMG_FMT_I420, video_width, video_height, 1);
    utox_video_frame.y = input.planes[0];
    utox_video_frame.u = input.planes[1];
    utox_video_frame.v = input.planes[2];
    utox_video_frame.w = input.d_w;
    utox_video_frame.h = input.d_h;

    LOG_NOTE("uToxVideo", "video init done!" );
    video_device_status = true;

    return true;
}
示例#3
0
文件: settings.c 项目: baloo79/uTox
// TODO refactor to match order in main.h
void config_save(UTOX_SAVE *save_in) {
    UTOX_SAVE *save = calloc(1, sizeof(UTOX_SAVE) + proxy_address_size);

    /* Copy the data from the in data to protect the calloc */
    save->window_x                      = save_in->window_x;
    save->window_y                      = save_in->window_y;
    save->window_width                  = save_in->window_width;
    save->window_height                 = save_in->window_height;

    save->save_version                  = UTOX_SAVE_VERSION;
    save->scale                         = ui_scale;
    save->proxyenable                   = switch_proxy.switch_on;
    save->audible_notifications_enabled = settings.ringtone_enabled;
    save->audio_filtering_enabled       = settings.audiofilter_enabled;
    save->push_to_talk                  = settings.push_to_talk;

    /* UX Settings */
    save->logging_enabled               = settings.logging_enabled;
    save->close_to_tray                 = settings.close_to_tray;
    save->start_in_tray                 = settings.start_in_tray;
    save->auto_startup                  = settings.start_with_system;
    save->use_mini_flist                = settings.use_mini_flist;
    save->magic_flist_enabled           = settings.magic_flist_enabled;
    save->use_long_time_msg             = settings.use_long_time_msg;

    save->video_fps                     = (settings.video_fps == 0) ? 25 : settings.video_fps;

    save->disableudp                    = !settings.enable_udp;
    save->enableipv6                    = settings.enable_ipv6;
    save->no_typing_notifications       = !settings.send_typing_status;

    save->filter                        = flist_get_filter();
    save->proxy_port                    = settings.proxy_port;
    save->force_proxy                   = settings.force_proxy;

    save->audio_device_in               = dropdown_audio_in.selected;
    save->audio_device_out              = dropdown_audio_out.selected;
    save->theme                         = settings.theme;

    save->utox_last_version             = settings.curr_version;
    save->group_notifications           = settings.group_notifications;
    save->status_notifications          = settings.status_notifications;

    save->auto_update                   = settings.auto_update;
    save->update_to_develop             = settings.update_to_develop;
    save->send_version                  = settings.send_version;

    save->language                      = settings.language;

    memcpy(save->proxy_ip, proxy_address, proxy_address_size);

    LOG_NOTE("uTox", "Saving uTox settings.");

    if (!utox_save_config(save)) {
        LOG_ERR("uTox", "Unable to save uTox settings.");
    }

    free(save);
}
示例#4
0
文件: main.cpp 项目: csioza/Dcore
int main (int argc, char *argv[])
{
    LOG_NOTE("============Start============");
    DBHUB->Init();
    ACCOUNTHUB->Init();
    network_start("../../bin/gate/netcfg.xml");
    static char * p = (char *)malloc(MAX_PACKET_SIZE);
    // 注册 
    p_near_register rpack;
    rpack.type = 1;
    rpack.index = server_index;
    get_client_ip_port(rpack.ip,rpack.port);
    send_one_packet((char*)&rpack);
    LOG_NOTE("============Loaded============");
    //
    u64 lastTime = 0;
    u64 elapse = 0;
    while (1)
    {
        packet * pack = proccess_packet(p);
        if (pack) dispatch_packet(pack);
        //=====================================
        //elapse += TIME->Elapse(lastTime);
        //if(elapse > 200)
        //{
        //    p_area_time pTime;
        //    TIME->SysNow();
        //    pTime.gid   = 1;
        //    pTime.guid  = 2;
        //    pTime.hour  = TIME->SysHour();
        //    pTime.min   = TIME->SysMin();
        //    pTime.sec   = TIME->SysSec();
        //    pTime.ms    = TIME->SysMs();
        //    send_one_packet((char *)&pTime);
        //    elapse = 0;
        //    LOG_INFO("gid:%d. sendTime[%d.%3d]",pTime.gid,pTime.sec,pTime.ms);
        //}
        sleep(1);
    }
    //
    network_close();
    getchar();
    return EXIT_SUCCESS;
}
示例#5
0
文件: toruby.c 项目: beoran/eruta
/** Writes a NOTE message to to log. */
static mrb_value tr_log(mrb_state * mrb, mrb_value self) {
  State   * state   = NULL;  
  (void) self; (void) mrb;
  
  mrb_value text    = mrb_nil_value();
  mrb_get_args(mrb, "S", &text);
  
  LOG_NOTE("%s\n", RSTRING_PTR(text));
  return self;
}
示例#6
0
文件: main.cpp 项目: csioza/Dcore
int main (int argc, char *argv[])
{
    LOG_NOTE("============Start============");
    DBHUB->Init();
    network_start("../../bin/ctrl/netcfg.xml");
    LOG_NOTE("============Loaded============");
    static char * p = (char *)malloc(MAX_PACKET_SIZE);
    while (1)
    {
        packet *pack = proccess_packet(p);
        if (pack) 
            dispatch_packet(pack);
        sleep(1);
    }
    //
    network_close();
    getchar();
    return EXIT_SUCCESS;
}
示例#7
0
文件: video.c 项目: Matsu616/uTox
bool utox_video_start(bool preview) {
    if (video_active) {
        LOG_NOTE("uToxVideo", "video already running" );
        return true;
    }

    if (!video_device_current) {
        LOG_NOTE("uToxVideo", "Not starting device None" );
        return false;
    }

    if (preview) {
        settings.video_preview = true;
    }

    if (video_device_init(video_device[video_device_current]) && video_device_start()) {
        video_active = true;
        LOG_NOTE("uToxVideo", "started video" );
        return true;
    }

    LOG_ERR("uToxVideo", "Unable to start video.");
    return false;
}
示例#8
0
  IIMGUIDriver::IIMGUIDriver(irr::IrrlichtDevice * const pDevice)
  {
    LOG_NOTE("{IrrIMGUI} Create Singleton Instance of IIMGUIDriver.\n");
    mInstances++;
    mTextureInstances = 0;

    FASSERT(mInstances == 1);

    pDevice->grab();
    mpDevice = pDevice;

    setupMouseControl();
    setupKeyControl();
    updateSettings();

    return;
  }
示例#9
0
  bool IIMGUIDriver::deleteInstance(void)
  {
    bool WasDeleted = false;

    if (mpInstance != nullptr)
    {
      LOG_NOTE("{IrrIMGUI} Delete Singleton Instance of IIMGUIDriver.\n");

      // delete font texture
      mpInstance->deleteTexture(mpFontTexture);
      mpFontTexture = nullptr;

      // delete instance
      delete(mpInstance);
      mpInstance = nullptr;
      mInstances = 0;
      FASSERT(ImGui::GetIO().MetricsAllocs == 0);

      WasDeleted = true;
    }

    return WasDeleted;
  }
示例#10
0
文件: settings.c 项目: baloo79/uTox
// TODO refactor to match same order in main.h
UTOX_SAVE *config_load(void) {
    UTOX_SAVE *save = utox_load_config();

    // TODO: Remove this in ~0.18.0 release
    if (!save) {
        LOG_NOTE("Settings", "Unable to load uTox settings from %s. Trying old %s.", config_file_name, config_file_name_old);
        save = utox_data_load_utox();
    }

    if (!save) {
        LOG_ERR("Settings", "Unable to load uTox settings. Use defaults.");
        save = init_default_settings();
    }

    if (save->scale > 30) {
        save->scale = 30;
    } else if (save->scale < 5) {
        save->scale = 10;
    }

    if (save->window_width < MAIN_WIDTH) {
        save->window_width = MAIN_WIDTH;
    }
    if (save->window_height < MAIN_HEIGHT) {
        save->window_height = MAIN_HEIGHT;
    }

    /* UX Settings */

    dropdown_language.selected = dropdown_language.over = settings.language = save->language;

    dropdown_dpi.selected = dropdown_dpi.over = save->scale - 5;

    switch_save_chat_history.switch_on = save->logging_enabled;
    switch_close_to_tray.switch_on     = save->close_to_tray;
    switch_start_in_tray.switch_on     = save->start_in_tray;
    switch_mini_contacts.switch_on     = save->use_mini_flist;
    switch_magic_sidebar.switch_on     = save->magic_flist_enabled;

    switch_ipv6.switch_on             = save->enableipv6;
    switch_udp.switch_on              = !save->disableudp;
    switch_udp.panel.disabled         = save->force_proxy;
    switch_proxy.switch_on            = save->proxyenable;
    switch_proxy_force.switch_on      = save->force_proxy;
    switch_proxy_force.panel.disabled = !save->proxyenable;

    switch_auto_startup.switch_on       = save->auto_startup;
    switch_auto_update.switch_on        = save->auto_update;

    settings.group_notifications = dropdown_global_group_notifications.selected =
        dropdown_global_group_notifications.over = save->group_notifications;

    switch_audible_notifications.switch_on = save->audible_notifications_enabled;
    switch_audio_filtering.switch_on       = save->audio_filtering_enabled;
    switch_push_to_talk.switch_on          = save->push_to_talk;
    switch_status_notifications.switch_on  = save->status_notifications;

    dropdown_theme.selected = dropdown_theme.over = save->theme;

    switch_typing_notes.switch_on = !save->no_typing_notifications;

    flist_set_filter(save->filter); /* roster list filtering */

    /* Network settings */
    settings.enable_ipv6 = save->enableipv6;
    settings.enable_udp  = !save->disableudp;
    settings.use_proxy   = !!save->proxyenable;
    settings.proxy_port  = save->proxy_port;
    settings.force_proxy = save->force_proxy;

    if (strlen((char *)save->proxy_ip) <= proxy_address_size){
        strcpy((char *)proxy_address, (char *)save->proxy_ip);
    }

    edit_proxy_ip.length = strlen((char *)save->proxy_ip);

    strcpy((char *)edit_proxy_ip.data, (char *)save->proxy_ip);

    if (save->proxy_port) {
        edit_proxy_port.length =
            snprintf((char *)edit_proxy_port.data, edit_proxy_port.maxlength + 1, "%u", save->proxy_port);
        if (edit_proxy_port.length >= edit_proxy_port.maxlength + 1) {
            edit_proxy_port.length = edit_proxy_port.maxlength;
        }
    }

    /* UX settings */
    settings.logging_enabled      = save->logging_enabled;
    settings.close_to_tray        = save->close_to_tray;
    settings.start_in_tray        = save->start_in_tray;
    settings.start_with_system    = save->auto_startup;
    settings.use_mini_flist       = save->use_mini_flist;
    settings.magic_flist_enabled  = save->magic_flist_enabled;
    settings.use_long_time_msg    = save->use_long_time_msg;

    settings.ringtone_enabled     = save->audible_notifications_enabled;
    settings.audiofilter_enabled  = save->audio_filtering_enabled;

    settings.send_typing_status   = !save->no_typing_notifications;
    settings.status_notifications = save->status_notifications;

    settings.window_width         = save->window_width;
    settings.window_height        = save->window_height;

    settings.last_version         = save->utox_last_version;

    loaded_audio_out_device       = save->audio_device_out;
    loaded_audio_in_device        = save->audio_device_in;

    settings.auto_update          = save->auto_update;
    switch_auto_update.switch_on  = save->auto_update;
    settings.update_to_develop    = save->update_to_develop;
    settings.send_version         = save->send_version;

    settings.video_fps = save->video_fps ? save->video_fps : 25;

    edit_video_fps.length =
        snprintf((char *)edit_video_fps.data, edit_video_fps.maxlength + 1, "%u", save->video_fps);
    if (edit_video_fps.length > edit_video_fps.maxlength) {
        edit_video_fps.length = edit_video_fps.maxlength;
    }

    // TODO: Don't clobber (and start saving) commandline flags.

    // Allow users to override theme on the cmdline.
    if (settings.theme == UINT32_MAX) {
        settings.theme = save->theme;
    }

    ui_set_scale(save->scale);

    if (save->push_to_talk) {
        init_ptt();
    }

    return save;
}
示例#11
0
/**
 * This is the main ticker of the engine. We'll call all the other tickers
 * from here.
 *
 * @param time  Duration of the tick. This will never be longer than 1.0/TICSPERSEC.
 */
static void baseTicker(timespan_t time)
{
    if(DD_IsFrameTimeAdvancing())
    {
#ifdef __CLIENT__
        // Demo ticker. Does stuff like smoothing of view angles.
        Demo_Ticker(time);
#endif
        P_Ticker(time);
#ifdef __CLIENT__
        FR_Ticker(time);
#endif

        // InFine ticks whenever it's active.
        App_InFineSystem().runTicks(time);

        // Game logic.
        if(App_GameLoaded() && gx.Ticker)
        {
            gx.Ticker(time);
        }

#ifdef __CLIENT__
        // Windowing system ticks.
        for(int i = 0; i < DDMAXPLAYERS; ++i)
        {
            R_ViewWindowTicker(i, time);
        }

        if(isClient)
        {
            Cl_Ticker(time);
        }
#elif __SERVER__
        Sv_Ticker(time);
#endif

        if(DD_IsSharpTick())
        {
            // Set frametime back by one tick (to stay in the 0..1 range).
            realFrameTimePos -= 1;

#ifdef __CLIENT__
            // Camera smoothing: now that the world tic has occurred, the next sharp
            // position can be processed.
            R_NewSharpWorld();
#endif

#ifdef LIBDENG_PLAYER0_MOVEMENT_ANALYSIS
            if(ddPlayers[0].shared.inGame && ddPlayers[0].shared.mo)
            {
                mobj_t* mo = ddPlayers[0].shared.mo;
                static coord_t prevPos[3] = { 0, 0, 0 };
                static coord_t prevSpeed = 0;
                coord_t speed = V2d_Length(mo->mom);
                coord_t actualMom[2] = { mo->origin[0] - prevPos[0], mo->origin[1] - prevPos[1] };
                coord_t actualSpeed = V2d_Length(actualMom);

                LOG_NOTE("%i,%f,%f,%f,%f")
                        << SECONDS_TO_TICKS(sysTime + time)
                        << ddPlayers[0].shared.forwardMove
                        << speed
                        << actualSpeed
                        << speed - prevSpeed;

                V3d_Copy(prevPos, mo->origin);
                prevSpeed = speed;
            }
#endif
        }

#ifdef __CLIENT__
        // While paused, don't modify frametime so things keep still.
        if(!clientPaused)
#endif
        {
            frameTimePos = realFrameTimePos;
        }
    }

    // Console is always ticking.
    Con_Ticker(time);
    if(tickFrame)
    {
        Con_TransitionTicker(time);
    }

    // Plugins tick always.
    DD_CallHooks(HOOK_TICKER, 0, &time);

    // The netcode gets to tick, too.
    Net_Ticker(time);
}
示例#12
0
文件: video.c 项目: Matsu616/uTox
void video_frame(uint16_t id, uint8_t *img_data, uint16_t width, uint16_t height, bool resize) {
    Window *win = &video_win[id];
    if (id == UINT16_MAX) {
        // Preview window
        win = &preview;
    }

    if  (!*win) {
        LOG_TRACE("Video", "frame for null window %u" , id);
        return;
    }

    if (resize) {
        XWindowChanges changes = {.width = width, .height = height };
        XConfigureWindow(display, *win, CWWidth | CWHeight, &changes);
    }

    XWindowAttributes attrs;
    XGetWindowAttributes(display, video_win[id], &attrs);

    XImage image = {
        .width            = attrs.width,
        .height           = attrs.height,
        .depth            = 24,
        .bits_per_pixel   = 32,
        .format           = ZPixmap,
        .byte_order       = LSBFirst,
        .bitmap_unit      = 8,
        .bitmap_bit_order = LSBFirst,
        .bytes_per_line   = attrs.width * 4,
        .red_mask         = 0xFF0000,
        .green_mask       = 0xFF00,
        .blue_mask        = 0xFF,
        .data             = (char *)img_data
    };

    /* scale image if needed */
    uint8_t *new_data = malloc(attrs.width * attrs.height * 4);
    if (new_data && (attrs.width != width || attrs.height != height)) {
        scale_rgbx_image(img_data, width, height, new_data, attrs.width, attrs.height);
        image.data = (char *)new_data;
    }

    GC     default_gc = DefaultGC(display, def_screen_num);
    Pixmap pixmap     = XCreatePixmap(display, main_window.window, attrs.width, attrs.height, default_depth);
    XPutImage(display, pixmap, default_gc, &image, 0, 0, 0, 0, attrs.width, attrs.height);
    XCopyArea(display, pixmap, *win, default_gc, 0, 0, attrs.width, attrs.height, 0, 0);
    XFreePixmap(display, pixmap);
    free(new_data);
}

void video_begin(uint16_t id, char *name, uint16_t name_length, uint16_t width, uint16_t height) {
    Window *win = &video_win[id];
    if (id == UINT16_MAX) {
        // Preview window
        win = &preview;
    }

    if (*win) {
        return;
    }

    *win = XCreateSimpleWindow(display, RootWindow(display, def_screen_num), 0, 0, width, height, 0,
                               BlackPixel(display, def_screen_num), WhitePixel(display, def_screen_num));

    // Fallback name in ISO8859-1.
    XStoreName(display, *win, "Video Preview");
    // UTF-8 name for those WMs that can display it.
    XChangeProperty(display, *win, XA_NET_NAME, XA_UTF8_STRING, 8, PropModeReplace, (uint8_t *)name, name_length);
    XSetWMProtocols(display, *win, &wm_delete_window, 1);

    /* set WM_CLASS */
    XClassHint hint = {.res_name = "utoxvideo", .res_class = "utoxvideo" };

    XSetClassHint(display, *win, &hint);

    XMapWindow(display, *win);
    LOG_TRACE("Video", "new window %u" , id);
}

void video_end(uint16_t id) {
    Window *win = &video_win[id];
    if (id == UINT16_MAX) {
        // Preview window
        win = &preview;
    }

    XDestroyWindow(display, *win);
    *win = None;
    LOG_NOTE("Video", "killed window %u" , id);
}