static BOOL CmdOnline(struct IOSana2Req *request, struct DevBase *base) { struct DevUnit *unit; BYTE error = 0; ULONG wire_error; UWORD i; /* Check request is valid */ unit = (APTR)request->ios2_Req.io_Unit; if((unit->flags & UNITF_CONFIGURED) == 0) { error = S2ERR_BAD_STATE; wire_error = S2WERR_NOT_CONFIGURED; } if((unit->flags & UNITF_HAVEADAPTER) == 0) { error = S2ERR_OUTOFSERVICE; wire_error = S2WERR_RCVREL_HDW_ERR; } /* Clear global and special stats and put adapter back online */ if((error == 0) && ((unit->flags & UNITF_ONLINE) == 0)) { unit->stats.PacketsReceived = 0; unit->stats.PacketsSent = 0; unit->stats.BadData = 0; unit->stats.Overruns = 0; unit->stats.UnknownTypesReceived = 0; unit->stats.Reconfigurations = 0; for(i = 0; i < STAT_COUNT; i++) unit->special_stats[i] = 0; GoOnline(unit, base); } /* Return */ request->ios2_Req.io_Error = error; request->ios2_WireError = wire_error; 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; } }
static BOOL CmdConfigInterface(struct IOSana2Req *request, struct DevBase *base) { struct DevUnit *unit; BYTE error = 0; ULONG wire_error; /* Configure adapter */ unit = (APTR)request->ios2_Req.io_Unit; if((unit->flags & UNITF_CONFIGURED) != 0) { error = S2ERR_BAD_STATE; wire_error = S2WERR_IS_CONFIGURED; } else if((unit->flags & UNITF_HAVEADAPTER) == 0) { error = S2ERR_BAD_STATE; wire_error = S2WERR_GENERIC_ERROR; } if(error == 0) { CopyMem(request->ios2_SrcAddr, unit->address, ETH_ADDRESSSIZE); ConfigureAdapter(unit, base); GoOnline(unit, base); unit->flags |= UNITF_CONFIGURED; } else { request->ios2_Req.io_Error = error; request->ios2_WireError = S2WERR_IS_CONFIGURED; } /* Return */ return TRUE; }
BeNetWindow::BeNetWindow() : BWindow(BRect(0,0,230,209),_T("Whisper"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE), //m_pBookmarksWindow(NULL), m_pPreferencesWindow(NULL), m_bShowStatusBar(true), m_bShowToolBar(true), m_isConnected(false) { // For connection to server TClient::Instance(); // For connection to user CNetwork::Instance()->SetWindow(this); // Load the preferences Preferences::Instance()->Load(); BRect b = Bounds(); AddChild(m_pMenu = new BeNetMenu(BRect(b.left, b.top, b.right, b.top + 12 ))); b = m_pMenu->Frame(); AddChild(m_pToolBar = new ToolBarView(BRect(b.left, b.bottom + 1, b.right, b.bottom + 40))); b = m_pToolBar->Frame(); AddChild(m_pConnectView = new ConnectView(BRect(b.left, b.bottom + 1, b.right, b.bottom + 230), !Preferences::Instance()->ShowConnection())); b = m_pConnectView->Frame(); // OliverESP: b.bottom + 97 <- ok AddChild(m_pScopeView = new ScopeView(BRect(b.left, b.bottom + 1, b.right, b.bottom + 97), !Preferences::Instance()->ShowOscilloscope())); b = m_pScopeView->Frame(); AddChild(m_pSoundControlsView = new SoundControlsView(BRect(b.left, b.bottom + 1, b.right, b.bottom + 51), !Preferences::Instance()->ShowSoundControls())); b = m_pSoundControlsView->Frame(); m_pSoundControlsView->Volume(Preferences::Instance()->RecordVolume()); AddChild(m_pStatusBar = new StatusBar(BRect(b.left, b.bottom + 1, b.right, b.bottom + 19))); b = m_pStatusBar->Frame(); ResizeTo(b.right, b.bottom - 1); MoveTo( Preferences::Instance()->MainX(), Preferences::Instance()->MainY()); // Initialize the recorder m_pRecorder = new Recorder(m_pScopeView); // Start recording // m_pRecorder->Record(); // Whisper Old sound engine m_pRecorder->StartRecording(); find_directory(B_USER_SETTINGS_DIRECTORY, &m_dirPath); m_dirPath.Append(PREFERENCES_FOLDER); create_directory(m_dirPath.Path(), 0777); m_prefsPath.Append(m_dirPath.Path()); m_bookmarksPath.Append(m_dirPath.Path()); m_pRemoteWindow = new RemoteWindow(this); m_pRemoteWindow->Run(); //m_pBookmarksWindow = new BookmarksWindow(m_pConnectView); //m_pBookmarksWindow->Run(); m_pPreferencesWindow = new PreferencesWindow; m_pPreferencesWindow->Run(); m_pAboutWindow = new AboutWindow; m_pAboutWindow->Run(); Output::Instance()->Run(); if (Preferences::Instance()->OnlineOnStartup()) GoOnline(); //if (Preferences::Instance()->ShowBookmarks()) // ShowWindow(m_pBookmarksWindow); if (Preferences::Instance()->ShowOutput()) ShowWindow(Output::Instance()); }
// ------------------------------------------------------------------------------------------------- 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; }
status_t MSNConnection::HandleUSR( Command * command ) { LOG(kProtocolName, liDebug, "C %lX: Processing USR", this); status_t result = B_ERROR; if (strcmp(command->Param(0), "OK") == 0) { Progress("MSN Login", "MSN: Logged in!", 1.0); GoOnline(); BMessage statusChange(msnmsgOurStatusChanged); statusChange.AddInt8("status", fState); fManMsgr.SendMessage(&statusChange); /* * Depending on the server protocol, server location and the * account being used (non-hotmail/msn acc), the server will not * respond on the PRP MFN command and our connection will break. * Michael */ BString passport(fManager->Passport()); if ((B_ERROR != passport.FindFirst("@hotmail")) || (B_ERROR != passport.FindFirst("@msn"))) { LOG(kProtocolName, liDebug, "Sending PRP MSN command" ); Command *rea = new Command("PRP"); rea->AddParam("MFN"); rea->AddParam(fManager->DisplayName(), true); Send(rea); } else { LOG(kProtocolName, liDebug, "Not sending PRP MSN command!"); }; fManager->Handler()->ContactList(&fContacts); Command *adl = new Command("ADL"); std::list<BString> contacts; std::map<BString, std::list<BString> > domainUsers; fManager->Handler()->ContactList(&contacts); // Make our contact list into a list by domain for (std::list<BString>::iterator iIt = contacts.begin(); iIt != contacts.end(); iIt++) { BString user; BString domain; if (SplitEmail((*iIt).String(), user, domain) == B_OK) { std::map<BString, std::list<BString> >::iterator dIt = domainUsers.find(domain); if (dIt == domainUsers.end()) { std::list<BString> users; users.push_back(user); domainUsers[domain] = users; } else { dIt->second.push_back(user); }; }; }; BString payload = "<ml l=\"1\">"; // Package each contact by domain for (std::map<BString, std::list<BString> >::iterator dIt = domainUsers.begin(); dIt != domainUsers.end(); dIt++) { payload << "<d n=\"" << dIt->first << "\">"; for (std::list<BString>::iterator uIt = dIt->second.begin(); uIt != dIt->second.end(); uIt++) { payload << "<c n=\"" << (*uIt) << "\" l=\"3\" t=\"1\" />"; }; payload << "</d>"; }; payload << "</ml>"; adl->AddPayload(payload.String()); Send(adl); Command *chg = new Command("CHG"); chg->AddParam("NLN"); BString caps = ""; caps << kOurCaps; chg->AddParam( caps.String() ); Send(chg); result = B_OK; } else { BString URI = command->Param(2); BString nonce = command->Param(3); BString authResp = ""; BString authToken = ""; SSO *auth = new SSO(NULL, fManager->Passport(), fManager->Password(), URI.String(), nonce.String()); result = auth->Response(authToken, authResp); if (result == B_OK) { Command *reply = new Command("USR"); reply->AddParam("SSO"); reply->AddParam("S"); reply->AddParam(authToken.String()); reply->AddParam(authResp.String()); reply->Debug(); Send(reply); }; }; return result; }