Пример #1
0
void proxy_init_all(void)
{
    pj_status_t status;

    global.port = 5060;
    global.record_route = 0;

    pj_log_set_level(5);

    status = init_stack();
    if (status != PJ_SUCCESS) {
        app_perror("Error initializing stack", status);
        return;
    }

    status = init_proxy();
    if (status != PJ_SUCCESS) {
        app_perror("Error initializing proxy", status);
        return;
    }

    status = init_stateful_proxy();
    if (status != PJ_SUCCESS) {
        app_perror("Error initializing stateful proxy", status);
        return;
    }

    return;
}
Пример #2
0
static void _setupProxy()
{
	char path[_MAX_PATH];
	GetModuleFileName(_Module.m_hInst, path, sizeof(path));
	extract_file_path(path);
	set_working_dir(path);
	init_proxy(
		0, 
		PROXY_SILENT | PROXY_ENABLE_BGLOADER | PROXY_ENABLE_DISPATCHER
		);
	initHisProxy();
	extern void hookEvents();
	hookEvents();
}
Пример #3
0
//albacore
int
call_common_set_sound_mode(CallSoundMode mode)
{
	g_debug("%s:%d setting sound mode (%d)", __FILE__, __LINE__, mode);

	DBusGProxy *proxy_vibrator;
	DBusGProxy *proxy_alsa;
	DBusGConnection *bus;
	GError *error = NULL;

	sound_mode = mode;
	int brightness = -1;
	int sound = -1;

	switch (sound_mode) {
	case CALL_SOUND_MODE_ACTIVE:
		brightness = 100;
		sound = 1;
		break;
	case CALL_SOUND_MODE_SILENT:
		brightness = 0;
		sound = 0;
		break;
	default:
		break;
	}

	g_type_init();
	bus = init_g_connection();

	if (init_proxy
	    (bus, &proxy_alsa, ODEVICED_BUS, DEVICE_AUDIO_PATH,
	     DEVICE_AUDIO_IFACE))
		return 1;
	if (sound == 1) {
		g_debug("Play Sound!\n");
		dbus_g_proxy_call(proxy_alsa, "PlaySound", &error,
				  G_TYPE_STRING, ringtone_name, G_TYPE_INT,
				  sound, G_TYPE_INT, sound_lenght,
				  G_TYPE_INVALID, G_TYPE_INVALID);
	}
	else if (sound == 0) {
		g_debug("Stop Sound!\n");
		if (!org_freesmartphone_Device_Audio_stop_sound
		    (proxy_alsa, ringtone_name, &error)) {
			g_debug("Stop Sound failed: %s", error->message);
			g_error_free(error);
		}
	}

	if (init_proxy
	    (bus, &proxy_vibrator, ODEVICED_BUS, DEVICE_VIBRATOR_PATH,
	     DEVICE_VIBRATOR_IFACE))
		return 1;
	if (brightness != -1) {
		if (!dbus_g_proxy_call
		    (proxy_vibrator, "SetBrightness", &error, G_TYPE_INT,
		     brightness, G_TYPE_INVALID, G_TYPE_INVALID)) {
			g_debug("Stop vibrator failed: %s", error->message);
			g_error_free(error);
		}
	}
	if (brightness == 100) {
		dbus_g_proxy_call(proxy_vibrator, "SetBlinking", &error,
				  G_TYPE_INT, on_duration, G_TYPE_INT,
				  off_duration, G_TYPE_INVALID, G_TYPE_INVALID);
	}
	return 0;
}
Пример #4
0
/*
 * main()
 */
int main(int argc, char *argv[])
{
    pj_status_t status;

    global.port = 5060;
    pj_log_set_level(4);

    status = init_options(argc, argv);
    if (status != PJ_SUCCESS)
	return 1;

    status = init_stack();
    if (status != PJ_SUCCESS) {
	app_perror("Error initializing stack", status);
	return 1;
    }

    status = init_proxy();
    if (status != PJ_SUCCESS) {
	app_perror("Error initializing proxy", status);
	return 1;
    }

    status = init_stateless_proxy();
    if (status != PJ_SUCCESS) {
	app_perror("Error initializing stateless proxy", status);
	return 1;
    }

#if PJ_HAS_THREADS
    status = pj_thread_create(global.pool, "sproxy", &worker_thread, 
			      NULL, 0, 0, &global.thread);
    if (status != PJ_SUCCESS) {
	app_perror("Error creating thread", status);
	return 1;
    }

    while (!global.quit_flag) {
	char line[10];

	puts("\n"
	     "Menu:\n"
	     "  q    quit\n"
	     "  d    dump status\n"
	     "  dd   dump detailed status\n"
	     "");

	if (fgets(line, sizeof(line), stdin) == NULL) {
	    puts("EOF while reading stdin, will quit now..");
	    global.quit_flag = PJ_TRUE;
	    break;
	}

	if (line[0] == 'q') {
	    global.quit_flag = PJ_TRUE;
	} else if (line[0] == 'd') {
	    pj_bool_t detail = (line[1] == 'd');
	    pjsip_endpt_dump(global.endpt, detail);
#if STATEFUL
	    pjsip_tsx_layer_dump(detail);
#endif
	}
    }

    pj_thread_join(global.thread);

#else
    puts("\nPress Ctrl-C to quit\n");
    for (;;) {
	pj_time_val delay = {0, 0};
	pjsip_endpt_handle_events(global.endpt, &delay);
    }
#endif

    destroy_stack();

    return 0;
}
Пример #5
0
int main(int argc, char **argv)
{
	int i;
	bool no_filenames = true;
	QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
	QApplication *application = new QApplication(argc, argv);
	(void)application;
	QStringList files;
	QStringList importedFiles;
	QStringList arguments = QCoreApplication::arguments();

	bool dedicated_console = arguments.length() > 1 &&
				 (arguments.at(1) == QString("--win32console"));
	subsurface_console_init(dedicated_console);

	for (i = 1; i < arguments.length(); i++) {
		QString a = arguments.at(i);
		if (a.at(0) == '-') {
			parse_argument(a.toLocal8Bit().data());
			continue;
		}
		if (imported) {
			importedFiles.push_back(a);
		} else {
			no_filenames = false;
			files.push_back(a);
		}
	}
#if !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR < 22
	git_threads_init();
#else
	git_libgit2_init();
#endif
	setup_system_prefs();
	if (uiLanguage(0).contains("-US"))
		default_prefs.units = IMPERIAL_units;
	prefs = default_prefs;
	fill_profile_color();
	parse_xml_init();
	taglist_init_global();
	init_ui();
	loadPreferences();
	// some hard coded settings
	prefs.animation_speed = 0; // we render the profile to pixmap, no animations

	// always show the divecomputer reported ceiling in red
	prefs.dcceiling = 1;
	prefs.redceiling = 1;

	init_proxy();
	if (no_filenames) {
		if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) {
			QString defaultFile(prefs.default_filename);
			if (!defaultFile.isEmpty())
				files.push_back(QString(prefs.default_filename));
		} else if (prefs.default_file_behavior == CLOUD_DEFAULT_FILE) {
			QString cloudURL;
			if (getCloudURL(cloudURL) == 0)
				files.push_back(cloudURL);
		}
	}

	if (!quit)
		run_ui();
	exit_ui();
	taglist_free(g_tag_list);
	parse_xml_exit();
	subsurface_console_exit();
	free_prefs();
	return 0;
}
Пример #6
0
BOOL CMcviewDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	init_proxy(
		m_hWnd, 
		PROXY_ENABLE_BGLOADER | PROXY_ENABLE_DISPATCHER
		);
	initHisProxy();

	// Set the icon for this dialog.  The framework does this automatically
	//	when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// name self, so that the successively coming instances
	// will find this window
	SetWindowText(MCVIEW_MAIN_DLG_NAME);

	// 设置控制板为全窗口宽,高度为全窗口宽的1/32
	RECT rectDesktop;
	::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop );
	int iW=rectDesktop.right;
	SetWindowPos(NULL,0,rectDesktop.bottom-iW/32,iW,iW/32,0);
	
	glTimer=0;
	ghNA=((CMcviewApp*)::AfxGetApp())->LoadIcon(IDI_NA);
	//显示窗口
	glViewWidth=iW;
	glViewHeight=rectDesktop.bottom-iW/32;
	theView.m_pCtrDlg=this;
	theView.Create(IDD_FVIEW_DIALOG);
	theView.MoveWindow(0,0,glViewWidth,glViewHeight);
	theView.ShowWindow(SW_SHOWNORMAL);
 
	//设置控件位置
	GetClientRect(&rectDesktop);
	//ClientToScreen(&rectDesktop);
	iW=rectDesktop.right-rectDesktop.left;
	int iH=rectDesktop.bottom-rectDesktop.top;
	CWnd* pContrl;
	//system button
	pContrl=GetDlgItem(IDC_SYSTEM);
	pContrl->MoveWindow(0,0,iW/24,iH);
	//key
	pContrl=GetDlgItem(IDC_KEY);
	pContrl->MoveWindow(iW-5*iW/24-iW/2-iW/6-2*iW/36,0,iW/24,iH);
	//index
	pContrl=GetDlgItem(IDC_INDEX);
	pContrl->MoveWindow(iW-4*iW/24-iW/2-iW/6-2*iW/36,0,iW/24,iH);
	//previous
	pContrl=GetDlgItem(IDC_PREVIOUS);
	pContrl->MoveWindow(iW-3*iW/24-iW/2-iW/6-2*iW/36,0,iW/36,iH);
	//next 
	pContrl=GetDlgItem(IDC_NEXT);
	pContrl->MoveWindow(iW-3*iW/24-iW/2-iW/6-iW/36,0,iW/36,iH);
	//loop
	pContrl=GetDlgItem(IDC_LOOP);
	pContrl->MoveWindow(iW-3*iW/24-iW/2-iW/6,0,iW/24,iH);
	//time lab
	pContrl=GetDlgItem(IDC_TIME);
	pContrl->MoveWindow(iW-2*iW/24-iW/2-iW/6,0,iW/6,iH);
	//alarm
	pContrl=GetDlgItem(IDC_ALARM);
	pContrl->MoveWindow(iW-2*iW/24-iW/2,0,iW/2,iH);
	//ack alarm
	pContrl=GetDlgItem(IDC_ACKALARM);
	pContrl->MoveWindow(iW-2*iW/24,0,iW/24,iH);
	//alarm list
	pContrl=GetDlgItem(IDC_ALARMLIST);
	pContrl->MoveWindow(iW-iW/24,0,iW/24,iH);
	
	//设置定时器
	m_nTimerRefresh=SetTimer(1,250,0);

	m_curView=0;

	m_viewList[m_curView] = g_startFile;
	theView.LoadFile(g_startFile);

	if(g_bEnableNoSwitch){
		SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
	}

	g_ProxyDispatchTable.OnAlarm = AlarmCallBack;
	g_ProxyDispatchTable.OnProgress = _OnProgress;
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}
Пример #7
0
int main( int argc, char *argv[] )
{
    int pid;


    /* read the arguments */
    td.connect = 1;
    td.logfile = NULL;
	LOG_INIT(NULL);//"/tmp/vlhttp-debug.log");
    LOG_SET_LEVEL(LOG_LEVEL_DBG);
    char opt;
    while((opt = getopt(argc, argv, "p:i:m:r:A:S:f")) != -1) {
        switch(opt) {
            case 'A':
                encode_base64(optarg, strlen(optarg), (unsigned char**)(&proxy_auth));
                DBG("proxy_auth: %s", proxy_auth);
                break;
            case 'S':
                encode_base64(optarg, strlen(optarg), (unsigned char**)(&sys_auth));
                DBG("sys_auth: %s", sys_auth);
                break;
            case 'r':
                strncpy(proxy_realm, optarg, sizeof(proxy_realm));
                break;
            case 'p':
                proxy_port = atoi(optarg);
                break;
            case 'i':
                td.auth_ip = inet_addr(optarg);
                break;
            case 'm':
                td.netmask = inet_addr(optarg);
                break;
            case 'f':
                DBG("turn off daemon", 0);
                foreground_mode = 1;
                break;
        }
    }

    td.auth_ip &= td.netmask;
    td.client_ip = 0;

	DBG("========================================================================================================", 0);

    /* is inetd mode enabled ? */

    if( proxy_port == 0 )
    {
		int r;
        td.client_fd = 0; /* stdin */

		DBG("start",0);
		r = proxy_thread( &td );
		DBG("exit with %d code", r);

        return( r );
    }

    /* fork into background */
    if (!foreground_mode) {
        if ( (pid = fork() ) < 0 ) {
            ERR("fork() fail", 0);
            return -1;
        }
        if (pid) return ( 0 );
    }


    if (!init_proxy()) {
        return -1;
    }

    while( 1 )
    {
        int n = sizeof( client_addr );

        /* wait for inboud connections */

        if( ( td.client_fd = accept( proxy_fd,
                (struct sockaddr *) &client_addr, (socklen_t*)&n ) ) < 0 )
        {
            ERR("accept() fail", 0);
            return -1;
        }

        td.client_ip = client_addr.sin_addr.s_addr;

        /* verify that the client is authorized */
        if ( (td.client_ip & td.netmask) != td.auth_ip ) {
            close( td.client_fd );
            continue;
        }

        /* fork a child to handle the connection */
        if ( (pid = fork()) < 0 ) {
            close( td.client_fd );
            continue;
        }

        if (pid) {
            /* in father; wait for the child to terminate */

            close( td.client_fd );
            waitpid( pid, NULL, 0 );
            continue;
        }

        /* in child; fork & exit so that father becomes init */
        if ((pid = fork()) < 0 ) {
            ERR("fork() fail", 0);
            return -1;
        }

        if (pid)
            return 0;

        return( proxy_thread( &td ) );

    }

    /* not reached */
    return -1;
}