Esempio n. 1
0
/******************************************************************************
*   MAIN function
******************************************************************************/
int main ( int argc, char **argv )
{

    Widget appShell = init_application(&argc, argv );
    catch_sigterm();
    trace_main = TRACE_MAIN;
    signal(SIGPIPE, SIG_IGN); /* ignore broken pipe on write */

    /*  -- Register all application specific callbacks and widget classes
     */
    RegisterApplication ( appShell );
    add_winmove_translations(appShell);

    /*  -- Create widget tree below toplevel shell using Xrm database
           register callbacks,actions, widget classe before
     */
    WcWidgetCreation ( appShell );

    /* get application resources and widget ptr */
    XtGetApplicationResources(	appShell, (XtPointer)&SETTINGS,
				basicSettingRes,
				XtNumber(basicSettingRes),
				(ArgList)0, 0 );
    SETTINGS.app = XtWidgetToApplicationContext(appShell);
    SETTINGS.vset = v_init();

    /* init widgets */
    trace_level = SETTINGS.traceLevel;
    TRACE(1,"Thermal1 %s\nThermal2 %s", SETTINGS.p[0], SETTINGS.p[1] );

    /*  init application functions
        All widgets are created, but not visible.
        functions can now communicate with widgets
    */
    update_cb(0,0); /* start timer */

    /*  -- Realize the widget tree and enter the main application loop
     */
    XtRealizeWidget ( appShell );
    grab_window_quit( appShell );
    make_borderless_window(appShell);
    make_stay_above(appShell);

    int x0,y0;
    if( load_window_position(&x0,&y0) == 0 )
        XMoveWindow(XtDisplay(appShell),XtWindow(appShell), x0, y0 );

    XtAppMainLoop(XtWidgetToApplicationContext(appShell)); /* use XtAppSetExitFlag */

    Dimension x,y;
    XtVaGetValues( appShell, "x", &x, "y", &y, NULL );
    save_window_position(x,y);

    XtDestroyWidget(appShell);
    v_free( SETTINGS.vset );
    m_destruct();
    return EXIT_SUCCESS;
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
// Function:    PrintMenu
// Purpose:     Prints a menu, retrieves the user selection, calls the handler, loops.
//              Returns when "Quit" is selected from the menu
// Parameters:  None
//
void RunMenu()
{
    HRESULT hr;
    WCHAR wzBuff[INPUT_BUFSIZE];
    int nInput;

    // Continuously show the menu to user and respond to their request
    //
    while (TRUE)
    {
        PrintMenu();

        fflush(stdin);
        hr = StringCbGets(wzBuff, sizeof(wzBuff));

        if (FAILED(hr))
        {
            wprintf (L"Invalid input, expected a number between 1 and 25 or Q to quit.\n");
            continue;
        }

        if  ((wcsncmp(wzBuff, L"Q", INPUT_BUFSIZE) == 0) || (wcsncmp(wzBuff, L"q", INPUT_BUFSIZE) == 0))
        {
            // break out of while loop.
            //
            break;
        }

        // since wtoi can't distinguish between 0 and an error, note that valid values start at 1, not 0    
        nInput = _wtoi(wzBuff);
        if (nInput < 1  || nInput > 25)
        {
            printf ("Invalid input, expected a number between 1 and 25 or Q to quit.\n");
            continue;
        }

        switch (nInput)
        {
            case 1:
                SignIn();
                break;

            case 2:
                SignOut();
                break;

            case 3:
                SignInOptions();
                break;

            case 4:
                SetEndpointName();
                break;

            case 5:
                GetEndpointName();
                break;

            case 6:
                DisplayEndpointInformation();
                break;

            case 7:
                EnumeratePeopleNearMe();
                break;

            case 8:
                AddEndpointAsContact();
                break;

            case 9:
                ExportContact();
                break;

            case 10:
                ParseContact();
                break;
            
            case 11:
                ImportContact();
                break;
            
            case 12:
                DeleteContact();
                break;

            case 13:
                EnumContacts();
                break;
            
            case 14:
                SetWatching();
                break;

            case 15:
                SetWatchPermissions();
                break;

            case 16:
                GetPresenceInformation();
                break;
                    
            case 17:
                SetPresenceInformation();
                break;

            case 18:
                SubscribeEndpointData();
                break;

            case 19:
                UnsubscribeEndpointData();
                break;

            case 20:
                PublishEndpointObject();
                break;

            case 21:
                DeleteEndpointObject();
                break;
                                    
            case 22:
                RegisterApplication();
                break;

            case 23:
                UnregisterApplication();
                break;

            case 24:
                DisplayApplicationRegistrations();
                break;

            case 25:
                SendInvite();
                break;

            default:
                wprintf(L"Invalid selection.\n");
                break;

        }

        //Pause so that our output doesn't scroll
        //off the screen before the user gets a change to
        //read it.
         wprintf(L"\n\nPress <ENTER> to continue.\n");
        fflush(stdin);
        (void)StringCbGets(wzBuff, sizeof(wzBuff));
    }
}
Esempio n. 3
0
/******************************************************************************
*   MAIN function
******************************************************************************/
int main ( int argc, char **argv )
{
    trace_main = TRACE_MAIN;

    XtAppContext app;
    m_init();
    XtSetLanguageProc (NULL, NULL, NULL);
    XawInitializeWidgetSet();

    /*  --  Intialize Toolkit creating the application shell
     */
    Widget appShell = XtOpenApplication (&app, APP_NAME,
             /* resources: can be set from argv */
             options, XtNumber(options),
	     &argc, argv,
	     fallback_resources,
	     sessionShellWidgetClass,
	     NULL, 0
	   );
    load_icon(XtDisplay(appShell));
    //    load_icon_default();

    /*  --  Enable Editres support
     */
    XtAddEventHandler(appShell, (EventMask) 0, True, _XEditResCheckMessages, NULL);

    XtAddCallback( appShell, XtNdieCallback, quit_cb, NULL );

    /*  --  not parsed options are removed by XtOpenApplication
            the only entry left should be the program name
    */
    if (argc != 1) { m_destruct(); syntax(); exit(1); }
    TopLevel = appShell;


    /*  --  Register all application specific
            callbacks and widget classes
    */
    RegisterApplication ( appShell );

    /*  --  Register all Athena and Public
            widget classes, CBs, ACTs
    */
    XpRegisterAll ( app );

    /*  --  Create widget tree below toplevel shell
            using Xrm database
    */
    WcWidgetCreation ( appShell );


    /*  -- Get application resources and widget ptrs
     */
    XtGetApplicationResources(	appShell, (XtPointer)&CWRI,
				CWRI_CONFIG_RES,
				XtNumber(CWRI_CONFIG_RES),
				(ArgList)0, 0 );

    InitializeApplication(appShell);

    /*  --  Realize the widget tree and enter
            the main application loop  */
    XtRealizeWidget ( appShell );
    /*  --  Set Icon for Window */
    set_app_icon(appShell);

    grab_window_quit( appShell );

    XtAppMainLoop ( app ); /* use XtAppSetExitFlag */
    XtDestroyWidget(appShell);
    m_destruct();

    return EXIT_SUCCESS;
}
Esempio n. 4
0
/******************************************************************************
*   MAIN function
******************************************************************************/
int main ( int argc, char **argv )
{
    trace_main = TRACE_MAIN;

    XtAppContext app;
    signal(SIGPIPE, SIG_IGN); /* ignore broken pipe on write */
    m_init();
    trace_level = trace_main;

    XtSetLanguageProc (NULL, NULL, NULL);
    XawInitializeWidgetSet();
    /*  -- Intialize Toolkit creating the application shell
     */
    Widget appShell = XtOpenApplication (&app, APP_NAME,
	     options, XtNumber(options),  /* resources: can be set from argv */
	     &argc, argv,
	     fallback_resources,
	     sessionShellWidgetClass,
	     NULL, 0
	   );

    /* enable Editres support */
    XtAddEventHandler(appShell, (EventMask) 0, True, _XEditResCheckMessages, NULL);

    XtAddCallback( appShell, XtNdieCallback, quit_gui, NULL );

    /* not parsed options are removed by XtOpenApplication
       the only entry left should be the program name
    */
    if (argc != 1) { m_destruct(); syntax(); exit(1); }

    TopLevel = appShell;


    /*  -- Register all application specific callbacks and widget classes
     */
    RegisterApplication ( appShell );

    /*  -- Register all Athena and Public widget classes, CBs, ACTs
     */
    XpRegisterAll ( app );

    /*  -- Create widget tree below toplevel shell using Xrm database
     */
    WcWidgetCreation ( appShell );

    /* get application resources and widget ptr */
    XtGetApplicationResources(	appShell, (XtPointer)&CONFIG,
				basicSettingRes,
				XtNumber(basicSettingRes),
				(ArgList)0, 0 );


    InitializeApplication(appShell);

    /*  -- Realize the widget tree and enter the main application loop
     */
    XtRealizeWidget ( appShell );
    grab_window_quit( appShell );


    XtAppMainLoop ( app ); /* use XtAppSetExitFlag */
    XtDestroyWidget(appShell);

    v_free(CONFIG.vset);
    m_destruct();

    return EXIT_SUCCESS;
}