//----------------------------------------------------------------------------- //! Lock code management //----------------------------------------------------------------------------- void tSiriusController::LockCode() { const int existingCode = tAudioSettings::Instance()->LockCode(); const bool lockEnabled = existingCode != 0; QString instruction = tr("4-digit number"); if (lockEnabled) { // Enter the current code to verify, then enter the new code if (Authorize() == false) { return; } } // Acquire new lock code bool accepted = false; int newCode = tInputDialog::GetInteger( 0, tr("Enter New Lock Code"), instruction, m_InitialLockCode, m_MinimumLockCode, m_MaximumLockCode, &accepted ); if (accepted == false || newCode == existingCode) { tMessageBox::Error( 0, tr("Lock"), tr( "Lock code not changed" ), tMessageBox::CLOSE ); return; } // Save it tAudioSettings::Instance()->SetLockCode(newCode); tMessageBox::Information( 0, tr("Lock"), tr("Lock code changed"), tMessageBox::CLOSE ); }
Pop3::Pop3(QWidget *parent) : QMainWindow(parent), ui(new Ui::Pop3) { ui->setupUi(this); QObject::connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(MyEventHandler())); QObject::connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(Authorize())); client = new Pop3Client(true); //QObject::connect(ui->pushButton_2, SIGNAL(clicked()), ui->textEdit_2, SLOT(setText(tr("Пробуем авторизоваться...")))); }
//----------------------------------------------------------------------------- //! Lock the current channel //----------------------------------------------------------------------------- void tSiriusController::LockChannel(bool doLock) { if (Authorize() == true) { tAudioSettings::Instance()->LockChannel(m_ChannelId, doLock); QString status = tr("Channel ") + ( doLock? tr("locked") : tr("unlocked") ); tMessageBox::Information( 0, tr("Lock"), status, tMessageBox::CLOSE ); } }
void AuthorizeEntry (ICLEntry *entry) { const auto account = entry->GetParentAccount (); const auto& id = entry->GetHumanReadableID (); account->Authorize (entry->GetQObject ()); account->RequestAuth (id); const auto& e = Util::MakeANCancel ("org.LeechCraft.Azoth", "org.LC.Plugins.Azoth.AuthRequestFrom/" + entry->GetEntryID ()); Core::Instance ().SendEntity (e); }
QTSS_Error QTSSSpamDefenseModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParams) { switch (inRole) { case QTSS_Register_Role: return Register(&inParams->regParams); case QTSS_Initialize_Role: return Initialize(&inParams->initParams); case QTSS_RereadPrefs_Role: return RereadPrefs(); case QTSS_RTSPAuthorize_Role: return Authorize(&inParams->rtspAuthParams); case QTSS_RTSPSessionClosing_Role: return SessionClosing(&inParams->rtspSessionClosingParams); } return QTSS_NoErr; }
static void PerformRequest(void) { char *method = getenv("REQUEST_METHOD"); char *role = getenv("FCGI_ROLE"); char *scriptName = PathTail(getenv("SCRIPT_NAME")); char *parent = ""; char *op = QueryLookup(getenv("QUERY_STRING"), "op"); char *item = QueryLookup(getenv("QUERY_STRING"), "item"); char *userId = getenv("SI_UID"); if(userId == NULL) { InvalidRequest("405", "Incorrect configuration, no user id"); goto done; } else { MarkThisCartActive(userId); } if(!strcmp(role, "RESPONDER")) { if(strcmp(method, "GET")) { InvalidRequest("405", "Only GET Method Allowed"); } else if(op == NULL || !strcmp(op, OP_DISPLAY_STORE)) { DisplayStore(scriptName, parent, userId, fcgiProcessId); } else if(!strcmp(op, OP_ADD_ITEM)) { AddItemToCart(scriptName, parent, userId, fcgiProcessId, item); } else if(!strcmp(op, OP_DISPLAY_CART)) { DisplayCart(scriptName, parent, userId, fcgiProcessId); } else if(!strcmp(op, OP_REMOVE_ITEM)) { RemoveItemFromCart(scriptName, parent, userId, fcgiProcessId, item); } else if(!strcmp(op, OP_PURCHASE)) { Purchase(scriptName, parent, userId, fcgiProcessId); } else { InvalidRequest("404", "Invalid 'op' argument"); } } else if(!strcmp(role, "AUTHORIZER")) { Authorize(userId); } else { InvalidRequest("404", "Invalid FastCGI Role"); } done: Free(scriptName); Free(op); Free(item); }
QTSS_Error QTSSDSAuthModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParams) { switch (inRole) { case QTSS_Register_Role: return Register(); case QTSS_Initialize_Role: return Initialize(&inParams->initParams); case QTSS_RereadPrefs_Role: return RereadPrefs(); case QTSS_RTSPAuthenticate_Role: if (sAuthenticationEnabled) return AuthenticateRTSPRequest(&inParams->rtspAthnParams); case QTSS_RTSPAuthorize_Role: if (sAuthenticationEnabled) return Authorize(&inParams->rtspRequestParams); case QTSS_Shutdown_Role: return Shutdown(); } return QTSS_NoErr; }
//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- // Check for locked channel before tuning void tSiriusController::TuneChannelAbsolute( int channel ) { if( m_UnlockDialogShowing == true ) { // we've already popped up the box, just ignore return; } else if (tAudioSettings::Instance()->IsLocked(channel) // channel is locked && m_LockOpened == false) // lock is closed { emit ShowingAuthorizeDialog(); // Tell user the reason for the pop up QString msg = QString::number(channel) + tr(": channel locked, please enter code"); if (Authorize(msg) == false) // authorization failed { return; } } m_rSiriusConnector.TuneChannelAbsolute(channel); }
bool CHttp::AllocHandles ( bool isbase64, int *status, bool checkauth) { DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION; unsigned long errnum; DWORD rec_timeout = RECIEVE_TIMEOUT; // override the 30 second timeout fixed in 12.11 wyString contenttype,contenttypestr; //wyInt32 ret; /* If a user has selected to use proxy server for Internet connection then we create a separate handle, send a dummy request and set the username, password The real data connection and transfer is done in another handle */ if (IsProxy () ) m_InternetSession = InternetOpen (TEXT(USER_AGENT), INTERNET_OPEN_TYPE_PROXY, GetProxy(), NULL, 0 ); else m_InternetSession = InternetOpen (TEXT(USER_AGENT), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 ); if (!m_InternetSession ) return false; InternetSetOption(m_InternetSession, INTERNET_OPTION_RECEIVE_TIMEOUT, &rec_timeout, sizeof(rec_timeout)); m_InternetConnect = InternetConnect (m_InternetSession, m_HostName, m_Port, m_UserName, m_Password, INTERNET_SERVICE_HTTP, 0L, 0L ); if (!m_InternetConnect ) return false; /* set the flags for internet connection and check if SSL required */ if (wcsicmp (m_Protocol, L"https" ) == 0 ) flags |= INTERNET_FLAG_SECURE; /* check for proxy or password protected authentication checkauth flag tells whether its required to be authenticated */ if (checkauth && !Authorize (&errnum) ) { *status = errnum; return false; } m_HttpOpenRequest = HttpOpenRequest(m_InternetConnect, L"POST", m_FileName, NULL, NULL, NULL, flags, 0L ); if (!m_HttpOpenRequest ) return false; //Content-Type contenttype.SetAs(m_contenttype); contenttypestr.Sprintf("Content-Type: %s\r\n", contenttype.GetString()); if (!HttpAddRequestHeaders(m_HttpOpenRequest, contenttypestr.GetAsWideChar () , (DWORD)-1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE ) ) return false; /*if (!HttpAddRequestHeaders(m_HttpOpenRequest, L"HTTP_USER_AGENT: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0\r\n", (DWORD)-1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE ) ) return false;*/ //changing user string for avoid update your browser bug if (!HttpAddRequestHeaders(m_HttpOpenRequest, L"HTTP_USER_AGENT: Mozilla/5.0 (Windows; U;Windows NT 6.3; en-US; rv:36.0) Gecko/20100101 Firefox/36.0\r\n", (DWORD)-1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE ) ) return false; if (isbase64 ) { if (!HttpAddRequestHeaders(m_HttpOpenRequest, L"Base64: yes\r\n", (DWORD)-1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE ) ) { assert (0 ); return false; } } return true; }
static bytebuff_t * paa_process(pana_session_t * pacs, bytebuff_t * datain) { paa_ctx_t * ctx = pacs->ctx; bytebuff_t * respData; pana_packet_t * pkt_in = NULL; pana_avp_node_t * tmpavplist = NULL; pana_avp_t * tmp_avp; if (datain != NULL) { dbg_hexdump(PKT_RECVD, "Packet-contents:", bytebuff_data(datain), datain->used); pkt_in = parse_pana_packet(datain); if (pkt_in == NULL) { dbg_printf(MSG_ERROR,"Packet is invalid"); clear_events(); return NULL; } } #define RTX_COUNTER (ctx->rtx_timer.count) #define RTX_MAX_NUM (cfg->rtx_max_count) // ---------- // State: ANY // ---------- // - - - - - - - - - - - - - (Re-transmissions)- - - - - - - - - - // RTX_TIMEOUT && Retransmit(); (no change) // RTX_COUNTER< // RTX_MAX_NUM // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (RTX_TIMEOUT && RTX_COUNTER < RTX_MAX_NUM) { clear_events(); Retransmit(pacs); } // - - - - - - - (Reach maximum number of transmissions)- - - - - - // (RTX_TIMEOUT && Disconnect(); CLOSED // RTX_COUNTER>= // RTX_MAX_NUM) || // SESS_TIMEOUT // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if ((RTX_TIMEOUT && RTX_COUNTER >= RTX_MAX_NUM) || SESS_TIMEOUT) { clear_events(); Disconnect(pacs); pacs->cstate = PAA_STATE_CLOSED; } if (PKT_RECVD) { // ------------------------- // State: ANY except INITIAL // ------------------------- // - - - - - - - - - - (liveness test initiated by peer)- - - - - - // Rx:PNR[P] Tx:PNA[P](); (no change) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (pacs->cstate != PAA_STATE_INITIAL) { if (RX_PNR_P(pkt_in)) { /* reset the event status */ clear_events(); TX_PNA_P(respData, NULL); } } // ------------------------- // State: ANY except WAIT_PNA_PING // ------------------------- // - - - - - - - - - - - - (liveness test response) - - - - - - - - // Rx:PNA[P] None(); (no change) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (pacs->cstate != PAA_STATE_WAIT_PNA_PING){ if (RX_PNA_P(pkt_in)) { clear_events(); /* just discard the packet because it's not meant occur in this phase */ } } } // ------------------------- // State: CLOSED // ------------------------- // - - - - - - - -(Catch all event on closed state) - - - - - - - - // ANY None(); CLOSED // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (pacs->cstate == PAA_STATE_CLOSED){ clear_events(); /* just discard the packet because it's not meant occur in this phase */ } while(ctx->event_occured) { switch (pacs->cstate) { // ------------------------------ // State: INITIAL (Initial State) // ------------------------------ case PAA_STATE_INITIAL: // ------------------------+--------------------------+------------ // - - - - - - - - (PCI and PAA initiated PANA) - - - - - - - - - // (Rx:PCI[] || if (OPTIMIZED_INIT == INITIAL // PAC_FOUND) Set) { // EAP_Restart(); // SessionTimerReStart // (FAILED_SESS_TIMEOUT); // } // else { // if (generate_pana_sa()) // Tx:PAR[S]("PRF-Algorithm", // "Integrity-Algorithm"); // else // Tx:PAR[S](); // } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (RX_PCI(pkt_in)) { clear_events(); if (OPTIMIZED_INIT) { EAP_Restart(pacs); SessionTimerReStart(pacs, FAILED_SESS_TIMEOUT); } else { if (generate_pana_sa()) { tmpavplist = AVPLIST(PAVP_PRF_ALG,"Integrity-Algorithm"); TX_PAR_S(respData, tmpavplist); } else { TX_PAR_S(respData, NULL); } } pacs->cstate = PAA_STATE_INITIAL; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // EAP_REQUEST if (generate_pana_sa()) INITIAL // Tx:PAR[S]("EAP-Payload", // "PRF-Algorithm", // "Integrity-Algorithm"); // else // Tx:PAR[S]("EAP-Payload"); // RtxTimerStart(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (EAP_REQUEST) { clear_events(); if (generate_pana_sa()) { tmpavplist = AVPLIST(PAVP_EAP_PAYLOAD,PAVP_PRF_ALG,"Integrity-Algorithm"); TX_PAR_S(respData, tmpavplist); } else{ tmpavplist = AVPLIST(PAVP_EAP_PAYLOAD); TX_PAR_S(respData, tmpavplist); } RtxTimerStart(pacs, respData); pacs->cstate = PAA_STATE_INITIAL; } // - - - - - - - - - - - - - - (PAN Handling) - - - - - - - - - - // Rx:PAN[S] && if (PAN.exist_avp WAIT_EAP_MSG // ((OPTIMIZED_INIT == ("EAP-Payload")) // Unset) || TxEAP(); // PAN.exist_avp else { // ("EAP-Payload")) EAP_Restart(); // SessionTimerReStart // (FAILED_SESS_TIMEOUT); // } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (RX_PAN_S(pkt_in) && ((!OPTIMIZED_INIT) || exists_avp(pkt_in, PAVP_EAP_PAYLOAD))) { clear_events(); pacs->seq_rx = pkt_in->pp_seq_number; tmp_avp = get_vend_avp_by_code(pkt_in->pp_avp_list, PAVP_PEER_MACADDR, PANA_VENDOR_UPB, AVP_GET_FIRST); if (tmp_avp) { memcpy(ctx->peer_macaddr, tmp_avp->avp_value, MACADDR_LEN); } if (exists_avp(pkt_in, PAVP_EAP_PAYLOAD)) { TxEAP(pacs, pkt_in); } else { EAP_Restart(pacs); SessionTimerReStart(pacs, FAILED_SESS_TIMEOUT); } pacs->cstate = PAA_STATE_WAIT_EAP_MSG; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Rx:PAN[S] && None(); WAIT_PAN_OR_PAR // (OPTIMIZED_INIT == // Set) && // ! PAN.exist_avp // ("EAP-Payload") // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (RX_PAN_S(pkt_in) &&(OPTIMIZED_INIT) && !exists_avp(pkt_in, PAVP_EAP_PAYLOAD)) { clear_events(); pacs->seq_rx = pkt_in->pp_seq_number; // None(); pacs->cstate = PAA_STATE_WAIT_PAN_OR_PAR; } break; // ------------------- // State: WAIT_EAP_MSG // ------------------- case PAA_STATE_WAIT_EAP_MSG: // - - - - - - - - - - - -(Receiving EAP-Request)- - - - - - - - - // EAP_REQUEST if (NONCE_SENT==Unset) { WAIT_PAN_OR_PAR // Tx:PAR[]("Nonce", // "EAP-Payload"); // NONCE_SENT=Set; // } // else // Tx:PAR[]("EAP-Payload"); // RtxTimerStart(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (EAP_REQUEST) { clear_events(); if (!NONCE_SENT) { tmpavplist = AVPLIST(PAVP_NONCE, PAVP_EAP_PAYLOAD); TX_PAR(respData, tmpavplist); NONCE_SENT_Set(); } else { tmpavplist = AVPLIST(PAVP_EAP_PAYLOAD); TX_PAR(respData, tmpavplist); } RtxTimerStart(pacs, respData); pacs->cstate = PAA_STATE_WAIT_PAN_OR_PAR; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - -(Receiving EAP-Success/Failure) - - - - - // EAP_FAILURE PAR.RESULT_CODE = WAIT_FAIL_PAN // PANA_AUTHENTICATION_ // REJECTED; // Tx:PAR[C]("EAP-Payload"); // RtxTimerStart(); // SessionTimerStop(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (EAP_FAILURE) { clear_events(); tmpavplist = AVPLIST(PAVP_RESULT_AUTHENTICATION_REJECTED, PAVP_EAP_PAYLOAD); TX_PAR_C(respData, tmpavplist); RtxTimerStart(pacs, respData); SessionTimerStop(pacs); pacs->cstate = PAA_STATE_WAIT_FAIL_PAN; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // EAP_SUCCESS && PAR.RESULT_CODE = WAIT_SUCC_PAN // Authorize() PANA_SUCCESS; // if (new_key_available()) // Tx:PAR[C]("EAP-Payload", // "Key-Id"); // else // Tx:PAR[C]("EAP-Payload"); // RtxTimerStart(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (EAP_SUCCESS && Authorize(pacs)) { clear_events(); if (new_key_available()) { tmpavplist = AVPLIST(PAVP_RESULT_SUCCESS, PAVP_EAP_PAYLOAD,"Key-Id"); TX_PAR_C(respData, tmpavplist); } else{ tmpavplist = AVPLIST(PAVP_RESULT_SUCCESS, PAVP_EAP_PAYLOAD); TX_PAR_C(respData, tmpavplist);} RtxTimerStart(pacs, respData); pacs->cstate = PAA_STATE_WAIT_SUCC_PAN; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // EAP_SUCCESS && PAR.RESULT_CODE = WAIT_FAIL_PAN // !Authorize() PANA_AUTHORIZATION_ // REJECTED; // if (new_key_available()) // Tx:PAR[C]("EAP-Payload", // "Key-Id"); // else // Tx:PAR[C]("EAP-Payload"); // RtxTimerStart(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (EAP_SUCCESS && !Authorize(pacs)) { clear_events(); if (new_key_available()) { tmpavplist = AVPLIST(PAVP_RESULT_AUTHORIZATION_REJECTED ,PAVP_EAP_PAYLOAD,"Key-Id"); TX_PAR_C(respData, tmpavplist); }else{ tmpavplist = AVPLIST(PAVP_RESULT_AUTHORIZATION_REJECTED, PAVP_EAP_PAYLOAD); TX_PAR_C(respData, tmpavplist); } RtxTimerStart(pacs, respData); pacs->cstate = PAA_STATE_WAIT_FAIL_PAN; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - (Receiving EAP-Timeout or invalid message) - - - - - // EAP_TIMEOUT || SessionTimerStop(); CLOSED // EAP_DISCARD Disconnect(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (EAP_TIMEOUT || EAP_DISCARD) { clear_events(); SessionTimerStop(pacs); Disconnect(pacs); pacs->cstate = PAA_STATE_CLOSED; } break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // -------------------- // State: WAIT_SUCC_PAN // -------------------- case PAA_STATE_WAIT_SUCC_PAN: // - - - - - - - - - - - - - (PAN Processing)- - - - - - - - - - - // Rx:PAN[C] RtxTimerStop(); OPEN // SessionTimerReStart // (LIFETIME_SESS_TIMEOUT); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (RX_PAN_C(pkt_in)) { clear_events(); RtxTimerStop(pacs); SessionTimerReStart(pacs, LIFETIME_SESS_TIMEOUT); pacs->cstate = PAA_STATE_OPEN; } break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // -------------------- // State: WAIT_FAIL_PAN // -------------------- case PAA_STATE_WAIT_FAIL_PAN: // - - - - - - - - - - - - - - (PAN Processing)- - - - - - - - - - // Rx:PAN[C] RtxTimerStop(); CLOSED // Disconnect(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (RX_PAN_C(pkt_in)) { clear_events(); RtxTimerStop(pacs); Disconnect(pacs); pacs->cstate = PAA_STATE_CLOSED; } break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ----------- // State: OPEN // ----------- case PAA_STATE_OPEN: // - - - - - - - - (re-authentication initiated by PaC) - - - - - - // Rx:PNR[A] NONCE_SENT=Unset; WAIT_EAP_MSG // EAP_Restart(); // Tx:PNA[A](); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (RX_PNR_A(pkt_in)) { clear_events(); NONCE_SENT_Unset(); EAP_Restart(pacs); TX_PNA_A(respData, NULL); pacs->cstate = PAA_STATE_WAIT_EAP_MSG; } // - - - - - - - - (re-authentication initiated by PAA)- - - - - - // REAUTH || NONCE_SENT=Unset; WAIT_EAP_MSG // REAUTH_TIMEOUT EAP_Restart(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* will require the PaC to reauth */ else if (REAUTH ) { clear_events(); NONCE_SENT_Unset(); EAP_Restart(pacs); pacs->cstate = PAA_STATE_WAIT_EAP_MSG; } // - - (liveness test based on PNR-PNA exchange initiated by PAA)- // PANA_PING Tx:PNR[P](); WAIT_PNA_PING // RtxTimerStart(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (PANA_PING) { clear_events(); TX_PNR_P(respData, NULL); RtxTimerStart(pacs, respData); pacs->cstate = PAA_STATE_WAIT_PNA_PING; } // - - - - - - - - (Session termination initated from PAA) - - - - // TERMINATE Tx:PTR[](); SESS_TERM // SessionTimerStop(); // RtxTimerStart(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (TERMINATE) { clear_events(); TX_PTR(respData, NULL); SessionTimerStop(pacs); RtxTimerStart(pacs, respData); pacs->cstate = PAA_STATE_SESS_TERM; } // - - - - - - - - (Session termination initated from PaC) - - - - // Rx:PTR[] Tx:PTA[](); CLOSED // SessionTimerStop(); // Disconnect(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (RX_PTR(pkt_in)) { clear_events(); TX_PTA(respData, NULL); SessionTimerStop(pacs); Disconnect(pacs); pacs->cstate = PAA_STATE_CLOSED; } break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // -------------------- // State: WAIT_PNA_PING // -------------------- case PAA_STATE_WAIT_PNA_PING: // - - - - - - - - - - - - - -(PNA processing) - - - - - - - - - - // Rx:PNA[P] RtxTimerStop(); OPEN // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (RX_PNA_P(pkt_in)) { clear_events(); RtxTimerStop(pacs); pacs->cstate = PAA_STATE_OPEN; } // - - - - - - - - (re-authentication initiated by PaC) - - - - - - // Rx:PNR[A] RtxTimerStop(); WAIT_EAP_MSG // NONCE_SENT=Unset; // EAP_Restart(); // Tx:PNA[A](); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (RX_PNR_A(pkt_in)) { clear_events(); RtxTimerStop(pacs); NONCE_SENT_Unset(); EAP_Restart(pacs); TX_PNA_A(respData, NULL); pacs->cstate = PAA_STATE_WAIT_EAP_MSG; } // - - - - - - - - (Session termination initated from PaC) - - - - // Rx:PTR[] RtxTimerStop(); CLOSED // Tx:PTA[](); // SessionTimerStop(); // Disconnect(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if ( RX_PTR(pkt_in)) { clear_events(); RtxTimerStop(pacs); TX_PTA(respData, NULL); SessionTimerStop(pacs); Disconnect(pacs); pacs->cstate = PAA_STATE_CLOSED; } break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ---------------------- // State: WAIT_PAN_OR_PAR // ---------------------- case PAA_STATE_WAIT_PAN_OR_PAR: // - - - - - - - - - - - - - (PAR Processing)- - - - - - - - - - - // Rx:PAR[] TxEAP(); WAIT_EAP_MSG // RtxTimerStop(); // Tx:PAN[](); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (RX_PAR(pkt_in)) { clear_events(); TxEAP(pacs, pkt_in); RtxTimerStop(pacs); TX_PAN(respData, NULL); pacs->cstate = PAA_STATE_WAIT_EAP_MSG; } // - - - - - - (Pass EAP Response to the EAP authenticator)- - - - // Rx:PAN[] && TxEAP(); WAIT_EAP_MSG // PAN.exist_avp RtxTimerStop(); // ("EAP-Payload") // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (RX_PAN(pkt_in) && exists_avp(pkt_in, PAVP_EAP_PAYLOAD)) { clear_events(); TxEAP(pacs, pkt_in); RtxTimerStop(pacs); pacs->cstate = PAA_STATE_WAIT_EAP_MSG; } // - - - - - - - - - - (PAN without an EAP response) - - - - - - - // Rx:PAN[] && RtxTimerStop(); WAIT_PAN_OR_PAR // !PAN.exist_avp // ("EAP-Payload") // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (RX_PAN(pkt_in) && !exists_avp(pkt_in, PAVP_EAP_PAYLOAD)) { clear_events(); RtxTimerStop(pacs); pacs->cstate = PAA_STATE_WAIT_PAN_OR_PAR; } // - - - - - - - - - - - -(EAP retransmission) - - - - - - - - - - // EAP_REQUEST RtxTimerStop(); WAIT_PAN_OR_PAR // Tx:PAR[]("EAP-Payload"); // RtxTimerStart(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (EAP_REQUEST) { clear_events(); RtxTimerStop(pacs); tmpavplist = AVPLIST(PAVP_EAP_PAYLOAD); TX_PAR(respData, tmpavplist); RtxTimerStart(pacs, respData); pacs->cstate = PAA_STATE_WAIT_PAN_OR_PAR; } // - - - - - - - (EAP authentication timeout or failure)- - - - - // EAP_FAILURE || RtxTimerStop(); CLOSED // EAP_TIMEOUT || SessionTimerStop(); // EAP_DISCARD Disconnect(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if (EAP_FAILURE || EAP_TIMEOUT ||EAP_DISCARD ) { clear_events(); RtxTimerStop(pacs); SessionTimerStop(pacs); Disconnect(pacs); pacs->cstate = PAA_STATE_CLOSED; } break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ---------------- // State: SESS_TERM // ---------------- case PAA_STATE_SESS_TERM: // - - - - - - - - - - - - - -(PTA processing) - - - - - - - - - - // Rx:PTA[] RtxTimerStop(); CLOSED // Disconnect(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (RX_PTA(pkt_in)) { clear_events(); RtxTimerStop(pacs); Disconnect(pacs); pacs->cstate = PAA_STATE_CLOSED; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* End switch */ } } if (respData == NULL) { return NULL; } dbgi_asciihexdump(respData,"replycontents:",bytebuff_data(respData), respData->used); return respData; }
void JabberProtocol::OnTag(XMLEntity *entity) { char buffer[4096]; // general buffer space static int seen_streams = 0; if (entity->IsCompleted() && !strcasecmp(entity->Name(), "iq")) { // handle roster retrival if (entity->Child("query") && entity->Child("query")->Attribute("xmlns") && !strcasecmp(entity->Child("query")->Attribute("xmlns"),"jabber:iq:roster")) { ParseRosterList(entity); return; } // handle session retrival if (entity->Attribute("id") && entity->Attribute("type") && !strcasecmp(entity->Attribute("type"), "result") && !strcasecmp(entity->Attribute("id"), "sess_1")) { release_sem(logged); mainWindow->Lock(); mainWindow->PostMessage(JAB_LOGGED_IN); mainWindow->Unlock(); return; } // handle binding retrival if (entity->Attribute("id") && entity->Attribute("type") && !strcasecmp(entity->Attribute("type"), "result") && !strcasecmp(entity->Attribute("id"), "bind_0")) { jid = BString(entity->Child("bind")->Child("jid")->Data()); fprintf(stderr, "JID: %s.\n", jid.String()); Session(); return; } if (entity->Attribute("type") && entity->Child("query") && !strcasecmp(entity->Attribute("type"), "result") && entity->Child("query", "xmlns", "jabber:iq:register")) { Authorize(); return; } if (entity->Attribute("type") && entity->Attribute("id") && !strcasecmp(entity->Attribute("type"), "result") && !strcasecmp(entity->Attribute("id"), "request_room_info")) { BMessage msg(JAB_PREFERENCES_DATAFORM); msg.AddPointer("XMLEntity", entity); MessageRepeater::Instance()->PostMessage(&msg); return; } if (entity->Attribute("type") && entity->Attribute("id") && !strcasecmp(entity->Attribute("type"), "error")) { if (!strcasecmp(entity->Attribute("id"), "storage_request")) { _storage_supported = false; return; } else if (!strcasecmp(entity->Attribute("id"), "save_conferences")) { _storage_supported = false; sprintf(buffer, "Storage XEP-0049 is not supported on server. Cannot save conferences.\n\nNext time will try save to roster."); ModalAlertFactory::Alert(buffer, "Pity", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); return; } else if (!strcasecmp(entity->Attribute("id"), "request_room_info")) { if (entity->Child("error") && entity->Child("error")->Child("text") && entity->Child("error")->Attribute("code")) sprintf(buffer, "Error %s:\n\n%s", entity->Child("error")->Attribute("code"), entity->Child("error")->Child("text")->Data()); else sprintf(buffer, "Error %s", entity->Child("error")->Attribute("code")); ModalAlertFactory::Alert(buffer, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); return; } if (entity->Child("error") && entity->Child("error")->Child("text") && entity->Child("error")->Attribute("code")) sprintf(buffer, "Error %s:\n\n%s", entity->Child("error")->Attribute("code"), entity->Child("error")->Child("text")->Data()); else sprintf(buffer, "Error %s", entity->Child("error")->Attribute("code")); ModalAlertFactory::Alert(buffer, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); Disconnect(); return; } if (entity->Attribute("id") && entity->Child("query") && entity->Child("query")->Attribute("xmlns") && entity->Attribute("type") && !strcasecmp(entity->Attribute("id"), "storage_request") && !strcasecmp(entity->Attribute("type"), "result") && !strcasecmp(entity->Child("query")->Attribute("xmlns"), "jabber:iq:private")) { if (entity->Child("query")->Child("storage")) ParseStorage(entity->Child("query")->Child("storage")); return; } if (entity->Attribute("type") && !strcasecmp(entity->Attribute("type"), "get")) { BString iq_from; BString iq_id; if (entity->Attribute("from")) { iq_from = BString(entity->Attribute("from")); } if (entity->Attribute("id")) { iq_id = BString(entity->Attribute("id")); } // handle version request XMLEntity *query = entity->Child("query"); if (query && query->Attribute("xmlns")) { if (!strcasecmp(query->Attribute("xmlns"), "jabber:iq:version")) { ProcessVersionRequest(iq_id, iq_from); } } // handle version request query = entity->Child("ping"); if (query && query->Attribute("xmlns")) { if (!strcasecmp(query->Attribute("xmlns"), "urn:xmpp:ping")) { Pong(iq_id, iq_from); } } return; } fprintf(stderr, "Unknown IQ message.\n"); return; } // handle authorization success if (entity->IsCompleted() && !strcasecmp(entity->Name(), "success")) { InitSession(); return; } // handle presence messages if (entity->IsCompleted() && !strcasecmp(entity->Name(), "presence")) { ProcessPresence(entity); return; } // handle stream error if (entity->IsCompleted() && !strcasecmp(entity->Name(), "stream:error")) { sprintf(buffer, "An stream error has occurred."); ModalAlertFactory::Alert(buffer, "Sorry", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); Disconnect(); return; } // handle stream error if (entity->IsCompleted() && !strcasecmp(entity->Name(), "stream:features")) { mainWindow->Lock(); int wantRegister = mainWindow->_login_new_account->Value(); mainWindow->Unlock(); if (wantRegister == B_CONTROL_ON) { if (entity->Child("register")) { mainWindow->Lock(); mainWindow->_login_new_account->SetValue(B_CONTROL_OFF); mainWindow->Unlock(); SendUserRegistration(user, pass, "haiku"); } else { sprintf(buffer, "Registration not supported on this server."); ModalAlertFactory::Alert(buffer, "Sorry", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); Disconnect(); } } else if (entity->Child("mechanisms")) Authorize(); else if (entity->Child("bind")) Bind(); else if (entity->Child("session")) Session(); return; } // handle failures if (entity->IsCompleted() && !strcasecmp(entity->Name(), "failure")) { if (entity->Child("not-authorized") != NULL) sprintf(buffer, "Not authorized failure."); else if (entity->Child("invalid-mechanism") != NULL) sprintf(buffer, "Invalid mechanism failure."); else if (entity->Child("invalid-authzid") != NULL) sprintf(buffer, "Invalid authorization Id."); else sprintf(buffer, "An failure occured."); ModalAlertFactory::Alert(buffer, "Sorry", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); Disconnect(); return; } // handle disconnection if (entity->IsCompleted() && !strcasecmp(entity->Name(), "stream:stream")) { ++seen_streams; if (seen_streams % 2 == 1) Disconnect(); return; } // handle incoming messages if (entity->IsCompleted() && !strcasecmp(entity->Name(), "message")) { //TalkManager::Instance()->Lock(); TalkManager::Instance()->ProcessMessageData(entity); //TalkManager::Instance()->Unlock(); return; } //delete entity; }