示例#1
0
static BOOL CmdOffline(struct IOSana2Req *request, struct DevBase *base)
{
   struct DevUnit *unit;

   /* Put adapter offline */

   unit = (APTR)request->ios2_Req.io_Unit;
   if((unit->flags & UNITF_ONLINE) != 0)
      GoOffline(unit, base);

   /* Return */

   return TRUE;
}
void
BeNetWindow::MessageReceived(BMessage* msg)
{
	switch (msg->what)
	{
		case MSG_SOUNDCONTROLS_VOLUME:
			Preferences::Instance()->RecordVolume(m_pSoundControlsView->Volume());
			m_pRecorder->SetRecVolume(((float)Preferences::Instance()->RecordVolume()/(float)100));
			break;
		case MSG_SOUNDCONTROLS_MUTE:
			if(m_pSoundControlsView->IsMute())
				m_pRecorder->StopRecording();
			else
//				m_pRecorder->Record();
				m_pRecorder->StartRecording();
			break;
		case MSG_MENU_EXIT:				// QuitRequested(); OliverESP: This will make be called twice in Zeta hmmmmmmm
										be_app_messenger.SendMessage(B_QUIT_REQUESTED);
										break;
		case MSG_MENU_TOOLBAR:			ToggleToolBar(); break; 
		case MSG_MENU_STATUSBAR:		ToggleStatusBar(); break; 
		case MSG_MENU_ABOUT:			ShowWindow(m_pAboutWindow); break;
		case MSG_MENU_OUTPUTWINDOW:		ShowWindow(Output::Instance()); break; 
		case MSG_MENU_PREFERENCES:		ShowWindow(m_pPreferencesWindow); break; 
		//case MSG_MENU_BOOKMARKS:		ShowWindow(m_pBookmarksWindow); break; 
		case MSG_MENU_MAILIP:			ShowMailIPWindow(); break; 
		case MSG_MENU_HELP:				LaunchHelp(); break; 
		case MENU_BOOKMARKS:			m_pConnectView->MessageReceived(msg); break;
		case MSG_MENU_CONNECT:			Connect(); break;
		case MSG_MENU_ACCEPT:			Accept(); break;
		case MSG_MENU_DISCONNECT:		Disconnect(); break; 
		case MSG_MENU_TERMINATE:		Terminate(); break; 
		case MSG_MENU_ONLINE:			GoOnline(); break; 
		case MSG_MENU_OFFLINE:			GoOffline(); break;
		
		case MSG_NOT_CONNECTED:			ToggleConection(false); // we receive this from the connectionView and this from the network 
										EnableActions(true);
										break; //OliverESP
		
		default:						BWindow::MessageReceived(msg); break;	 
	}
}
bool
BeNetWindow::QuitRequested(void)
{

	// Save the preferences
	Preferences::Instance()->Save();

	// Go offline
	if (TClient::Instance()->IsOnline())
		GoOffline();

	if (IsConnected())
		Disconnect();

	// Delete the recorder (pretend that it's recording)
	if (m_pRecorder != NULL) {        // OliverESP: we have to look out the pointer!
		m_pRecorder->StopRecording();
		delete m_pRecorder;
		m_pRecorder = NULL;
	}
	be_app_messenger.SendMessage(B_QUIT_REQUESTED);
	return true;
}
示例#4
0
文件: demo.c 项目: mbaglin/legato-af
// -------------------------------------------------------------------------------------------------
static bool ProcessCommand
(
    const char* textPtr,      ///< [IN] Check this text to see if it's a valid command.
    const char* requesterPtr  ///< [IN] If not NULL, then any response text is SMSed to this target.
)
{
    char buffer[10240];

    // Start looking for a match...
    if (strcmp(textPtr, "Crash") == 0)
    {
        // As the name implies, we are going to be crashing the application.  So simply append to
        // the output log and crash the app.  This is done to allow demonstration of the supervisor
        // policies.
        int x = 10;
        int y = 0;

        LE_ERROR("Something wicked this way comes...");
        LE_ERROR("Data result: %d", x / y);
    }
    else if (strcmp(textPtr, "Status") == 0)
    {
        // The status command allows the caller to query the current state of the modem.  A friendly
        // version of this status is constructed and returned to the caller.
        le_onoff_t radioStatus;
        const char * radioStatusPtr;
        le_mrc_NetRegState_t netRegState;
        uint32_t signalQuality;

        if(le_mrc_GetRadioPower(&radioStatus) != LE_OK)
        {
            radioStatusPtr = "in an unknown state";
        }
        else
        {
            radioStatusPtr = (radioStatus == LE_OFF) ? "off" : "on";
        }

        if(le_mrc_GetNetRegState(&netRegState) != LE_OK)
        {
            netRegState = LE_MRC_REG_UNKNOWN;
        }

        if(le_mrc_GetSignalQual(&signalQuality) != LE_OK)
        {
            signalQuality = 0;
        }

        sprintf(buffer, "The radio is %s and is %s. The signal strength is %s.",
                radioStatusPtr,
                GetNetStateString(netRegState),
                GetSignalString(signalQuality));
    }
    else if (strcmp(textPtr, "Sim") == 0)
    {
        // Like the status command, this command queries the underling hardware for information.
        // This information is turned into a string that can then be returned to the caller.
        le_sim_Id_t simId;
        le_sim_States_t simState;

        char iccid[100];
        char imsi[100];
        int pos = 0;

        simId = le_sim_GetSelectedCard();
        simState = le_sim_GetState(simId);

        pos += snprintf(buffer + pos, sizeof(buffer) - pos,
                "SIM %u is %s.",
                simId,
                GetSimStateString(simState));

        if(le_sim_GetICCID(simId, iccid, sizeof(iccid)) == LE_OK)
        {
            pos += snprintf(buffer + pos, sizeof(buffer) - pos,
                    " ICCID=%s", iccid);
        }

        if(le_sim_GetIMSI(simId, imsi, sizeof(imsi)) == LE_OK)
        {
            pos += snprintf(buffer + pos, sizeof(buffer) - pos,
                    " IMSI=%s", imsi);
        }

    }
    else if (strcmp(textPtr, "Online") == 0)
    {
        le_utf8_Copy(buffer, "Requesting data connection.", sizeof(buffer), NULL);
        GoOnline();
    }
    else if (strcmp(textPtr, "Offline") == 0)
    {
        le_utf8_Copy(buffer, "Releasing data connection.", sizeof(buffer), NULL);
        GoOffline(buffer);
    }
    else if (strcmp(textPtr, "TestDataConnectionV4") == 0)
    {
        TestDataConnectionV4(buffer);
    }
    else if (strcmp(textPtr, "TestDataConnectionV6") == 0)
    {
        TestDataConnectionV6(buffer);
    }
    else if (strcmp(textPtr, "Netinfo") == 0)
    {
        Netinfo(buffer);
    }
    else if (strcmp(textPtr, "DataInfo") == 0)
    {
        Datainfo(buffer);
    }
    else if (strcmp(textPtr, "DataReset") == 0)
    {
        DataReset(buffer);
    }
    else if (strcmp(textPtr, "Scan") == 0)
    {
        PerformScan(buffer, sizeof(buffer), requesterPtr);
    }
    else
    {
        return false;
    }

    // Check to see if any processing has occurred.  If so, check to see if the request came from a
    // local or remote requester.
    // If the requester was local, (requesterPtr == NULL) then simply log our response to the SMS log.
    // Otherwise, attempt to SMS the response string to the original caller.
    if (requesterPtr != NULL)
    {
        SendMessage(requesterPtr, buffer);
    }
    else if (OutputFilePtr != NULL)
    {
        fprintf(OutputFilePtr, "## %s ##\n", buffer);
        fflush(OutputFilePtr);
    }

    // Let the calling function know if we did any processing or not.
    return true;
}