// Reads from the given file. Returns false in case of error. bool Plumbing::DeSerialize(TFile* fp) { stack_.truncate(0); no_ = 0; // We will be modifying this as we AddToStack. int32_t size; if (fp->FReadEndian(&size, sizeof(size), 1) != 1) return false; for (int i = 0; i < size; ++i) { Network* network = CreateFromFile(fp); if (network == nullptr) return false; AddToStack(network); } if ((network_flags_ & NF_LAYER_SPECIFIC_LR) && !learning_rates_.DeSerialize(fp)) { return false; } return true; }
/* * See if finds a transparent background in image, and set its transparency * Return TRUE if found a transparent background */ BOOL MakeTransparentBkg(MCONTACT hContact, HBITMAP *hBitmap) { int i, j; BITMAP bmp; GetObject(*hBitmap, sizeof(bmp), &bmp); int width = bmp.bmWidth; int height = bmp.bmHeight; int colorDiff = db_get_w(hContact, "ContactPhoto", "TranspBkgColorDiff", db_get_w(0, AVS_MODULE, "TranspBkgColorDiff", 10)); // Min 5x5 to easy things in loop if (width <= 4 || height <= 4) return FALSE; DWORD dwLen = width * height * 4; BYTE *p = (BYTE *)malloc(dwLen); if (p == nullptr) return FALSE; HBITMAP hBmpTmp; if (bmp.bmBitsPixel == 32) hBmpTmp = *hBitmap; else // Convert to 32 bpp hBmpTmp = CopyBitmapTo32(*hBitmap); GetBitmapBits(hBmpTmp, dwLen, p); // **** Get corner colors // Top left BYTE colors[8][3]; BOOL foundBkg[8]; if (!GetColorForPoint(colorDiff, p, width, 0, 0, 0, 1, 1, 0, &foundBkg[0], &colors[0])) { if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); return FALSE; } // Top center if (!GetColorForPoint(colorDiff, p, width, width / 2, 0, width / 2 - 1, 0, width / 2 + 1, 0, &foundBkg[1], &colors[1])) { if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); return FALSE; } // Top Right if (!GetColorForPoint(colorDiff, p, width, width - 1, 0, width - 1, 1, width - 2, 0, &foundBkg[2], &colors[2])) { if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); return FALSE; } // Center left if (!GetColorForPoint(colorDiff, p, width, 0, height / 2, 0, height / 2 - 1, 0, height / 2 + 1, &foundBkg[3], &colors[3])) { if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); return FALSE; } // Center left if (!GetColorForPoint(colorDiff, p, width, width - 1, height / 2, width - 1, height / 2 - 1, width - 1, height / 2 + 1, &foundBkg[4], &colors[4])) { if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); return FALSE; } // Bottom left if (!GetColorForPoint(colorDiff, p, width, 0, height - 1, 0, height - 2, 1, height - 1, &foundBkg[5], &colors[5])) { if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); return FALSE; } // Bottom center if (!GetColorForPoint(colorDiff, p, width, width / 2, height - 1, width / 2 - 1, height - 1, width / 2 + 1, height - 1, &foundBkg[6], &colors[6])) { if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); return FALSE; } // Bottom Right if (!GetColorForPoint(colorDiff, p, width, width - 1, height - 1, width - 1, height - 2, width - 2, height - 1, &foundBkg[7], &colors[7])) { if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); return FALSE; } // **** X corners have to have the same color int count = 0; for (i = 0; i < 8; i++) if (foundBkg[i]) count++; if (count < db_get_w(hContact, "ContactPhoto", "TranspBkgNumPoints", db_get_w(0, AVS_MODULE, "TranspBkgNumPoints", 5))) { if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); return FALSE; } // Ok, X corners at least have a color, lets compare then int maxCount = 0, selectedColor = 0; for (i = 0; i < 8; i++) { if (foundBkg[i]) { count = 0; for (j = 0; j < 8; j++) { if (foundBkg[j] && ColorsAreTheSame(colorDiff, (BYTE *)&colors[i], (BYTE *)&colors[j])) count++; } if (count > maxCount) { maxCount = count; selectedColor = i; } } } if (maxCount < db_get_w(hContact, "ContactPhoto", "TranspBkgNumPoints", db_get_w(0, AVS_MODULE, "TranspBkgNumPoints", 5))) { // Not enought corners with the same color if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); return FALSE; } // Get bkg color as mean of colors { int bkgColor[3]; bkgColor[0] = 0; bkgColor[1] = 0; bkgColor[2] = 0; for (i = 0; i < 8; i++) { if (foundBkg[i] && ColorsAreTheSame(colorDiff, (BYTE *)&colors[i], (BYTE *)&colors[selectedColor])) { bkgColor[0] += colors[i][0]; bkgColor[1] += colors[i][1]; bkgColor[2] += colors[i][2]; } } bkgColor[0] /= maxCount; bkgColor[1] /= maxCount; bkgColor[2] /= maxCount; colors[selectedColor][0] = bkgColor[0]; colors[selectedColor][1] = bkgColor[1]; colors[selectedColor][2] = bkgColor[2]; } // **** Set alpha for the background color, from the borders if (hBmpTmp != *hBitmap) { DeleteObject(*hBitmap); *hBitmap = hBmpTmp; GetObject(*hBitmap, sizeof(bmp), &bmp); GetBitmapBits(*hBitmap, dwLen, p); } // Set alpha from borders bool transpProportional = (db_get_b(NULL, AVS_MODULE, "MakeTransparencyProportionalToColorDiff", 0) != 0); int *stack = (int *)malloc(width * height * 2 * sizeof(int)); if (stack == nullptr) { free(p); return FALSE; } // Put four corners int topPos = 0; AddToStack(stack, &topPos, 0, 0); AddToStack(stack, &topPos, width / 2, 0); AddToStack(stack, &topPos, width - 1, 0); AddToStack(stack, &topPos, 0, height / 2); AddToStack(stack, &topPos, width - 1, height / 2); AddToStack(stack, &topPos, 0, height - 1); AddToStack(stack, &topPos, width / 2, height - 1); AddToStack(stack, &topPos, width - 1, height - 1); int curPos = 0; while (curPos < topPos) { // Get pos int x = stack[curPos]; curPos++; int y = stack[curPos]; curPos++; // Get pixel BYTE *px1 = GET_PIXEL(p, x, y); // It won't change the transparency if one exists // (This avoid an endless loop too) // Not using == 255 because some MSN bmps have 254 in some positions if (px1[3] >= 253) { if (ColorsAreTheSame(colorDiff, px1, (BYTE *)&colors[selectedColor])) { px1[3] = (transpProportional) ? min(252, (abs(px1[0] - colors[selectedColor][0]) + abs(px1[1] - colors[selectedColor][1]) + abs(px1[2] - colors[selectedColor][2])) / 3) : 0; // Add 4 neighbours if (x + 1 < width) AddToStack(stack, &topPos, x + 1, y); if (x - 1 >= 0) AddToStack(stack, &topPos, x - 1, y); if (y + 1 < height) AddToStack(stack, &topPos, x, y + 1); if (y - 1 >= 0) AddToStack(stack, &topPos, x, y - 1); } } } free(stack); SetBitmapBits(*hBitmap, dwLen, p); free(p); return TRUE; }
CGUIDialogBoxeeWizardBase* CBoxeeLoginWizardManager::HandleNextAction(CGUIDialogBoxeeWizardBase* pDialog, bool& addCurrentDlgToStack) { if (!pDialog) { CLog::Log(LOGERROR,"CBoxeeLoginWizardManager::HandleNextAction - Enter function with a NULL pointer (blw)(digwiz)"); return NULL; } int id = pDialog->GetID(); CLog::Log(LOGDEBUG,"CBoxeeLoginWizardManager::HandleNextAction - Enter function with [id=%d] (blw)(digwiz)",id); CGUIDialogBoxeeWizardBase* pNextDialog = NULL; switch(id) { case WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_CHOOSE_USER_TO_ADD: { CGUIDialogBoxeeLoginWizardChooseUserToAddType* pAddUserDlg = (CGUIDialogBoxeeLoginWizardChooseUserToAddType*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_CHOOSE_USER_TO_ADD); if (!pAddUserDlg) { CLog::Log(LOGERROR,"CBoxeeLoginWizardManager::HandleNextAction - FAILED to get DialogBoxeeLoginWizardAddUser (blw)(digwiz)"); break; } if (pAddUserDlg->IsAddingNewUser()) { pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_ADD_NEW_USER); CLog::Log(LOGDEBUG,"CBoxeeLoginWizardManager::HandleNextAction - IsAddingNewUser returned TRUE (blw)(digwiz)"); } else { CLog::Log(LOGDEBUG,"CBoxeeLoginWizardManager::HandleNextAction - IsAddingNewUser returned FALSE. Set next dialog to ADD_EXISTING_USER (blw)(digwiz)"); pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_ADD_EXISTING_USER); } IsAddingDialogToStack(pNextDialog,addCurrentDlgToStack); } break; case WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_ADD_EXISTING_USER: { pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_MENU_CUST); } break; case WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_ADD_NEW_USER: { pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_NEW_USER_DETAILS); } break; case WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_NEW_USER_DETAILS: { pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_TOU); } break; case WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_TOU: { #ifdef HAS_EMBEDDED pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_CONNECT_SOCIAL_SERVICES); #else pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_MENU_CUST); #endif } break; case WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_CONNECT_SOCIAL_SERVICES: { pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_MENU_CUST); } break; case WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_MENU_CUST: { pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_CONFIRMATION); } break; case WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_CONFIRMATION: { #ifdef HAS_EMBEDDED if (strcmpi(BoxeeUtils::GetPlatformStr(),"dlink.dsm380") == 0) { CLog::Log(LOGDEBUG,"CBoxeeLoginWizardManager::HandleNextAction - [platform=%s] -> show RemoteQuickTip (blw)(digwiz)",BoxeeUtils::GetPlatformStr()); pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_QUICK_TIP); } else { pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_QUICK_TIP_AIRPLAY); } #else //pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_QUICK_TIP_AIRPLAY); SetWizardComplete(true); #endif } break; case WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_QUICK_TIP: { pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_QUICK_TIP_AIRPLAY); } break; case WINDOW_DIALOG_BOXEE_LOGIN_WIZARD_QUICK_TIP_AIRPLAY: { SetWizardComplete(true); } break; default: { CLog::Log(LOGERROR,"CBoxeeLoginWizardManager::HandleNextAction - FAILED to handle WindowId [%d] (blw)(digwiz)",id); } break; } if (addCurrentDlgToStack) { AddToStack(id); } else { CLog::Log(LOGDEBUG,"CBoxeeLoginWizardManager::HandleNextAction - Not adding [id=%d] to stack. [addCurrentDlgToStack=%d][DialogStackSize=%d] (blw)(digwiz)",id,addCurrentDlgToStack,GetStackSize()); } CLog::Log(LOGDEBUG,"CBoxeeLoginWizardManager::HandleNextAction - Exit function and return [NextDialog=%p] for [id=%d] (blw)(digwiz)",pNextDialog,id); return pNextDialog; }
CGUIDialogBoxeeWizardBase* CBoxeeOTAConfigurationManager::HandleNextAction(CGUIDialogBoxeeWizardBase* pDialog, bool& addCurrentDlgToStack) { if (!pDialog) { CLog::Log(LOGERROR,"CBoxeeOTAConfigurationManager::HandleNextAction - Enter function with a NULL pointer (digwiz)"); return NULL; } int id = pDialog->GetID(); CLog::Log(LOGDEBUG,"CBoxeeOTAConfigurationManager::HandleNextAction - Enter function with [id=%d] (digwiz)",id); CGUIDialogBoxeeWizardBase* pNextDialog = NULL; switch(id) { case WINDOW_OTA_WELCOME_CONFIGURATION: { m_data.ClearData(); m_data.DetectLocation(); // If we know the country, ask the user to confirm, otherwise let the user select the location BOXEE::BXCurrentLocation& location = BOXEE::BXCurrentLocation::GetInstance(); if (location.IsLocationDetected()) pNextDialog = (CGUIDialogBoxeeOTAConfirmLocation*)g_windowManager.GetWindow(WINDOW_OTA_LOCATION_CONFIRMATION); else pNextDialog = (CGUIDialogBoxeeOTACountriesLocationConfiguration*)g_windowManager.GetWindow(WINDOW_OTA_COUNTRIES_CONFIGURATION); if (pNextDialog) addCurrentDlgToStack = true; } break; case WINDOW_OTA_LOCATION_CONFIRMATION: { CGUIDialogBoxeeOTAConfirmLocation* pLocationDialog = (CGUIDialogBoxeeOTAConfirmLocation*)g_windowManager.GetWindow(WINDOW_OTA_LOCATION_CONFIRMATION); if (!pLocationDialog) break; if (pLocationDialog->GetYesButtonPressed() && m_data.IsInNorthAmerica()) pNextDialog = (CGUIDialogBoxeeOTAZipcodeLocationConfiguration*)g_windowManager.GetWindow(WINDOW_OTA_ZIPCODE_CONFIGURATION); else if (pLocationDialog->GetYesButtonPressed() && !m_data.IsInNorthAmerica() && !m_isConnectedToFacebook) pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_OTA_FACEBOOK_CONNECT); else if (pLocationDialog->GetYesButtonPressed() && !m_data.IsInNorthAmerica() && m_isConnectedToFacebook) SetWizardComplete(true); else pNextDialog = (CGUIDialogBoxeeOTACountriesLocationConfiguration*)g_windowManager.GetWindow(WINDOW_OTA_COUNTRIES_CONFIGURATION); if (pNextDialog) addCurrentDlgToStack = true; } break; case WINDOW_OTA_COUNTRIES_CONFIGURATION: { if (m_data.IsInNorthAmerica()) pNextDialog = (CGUIDialogBoxeeOTAZipcodeLocationConfiguration*)g_windowManager.GetWindow(WINDOW_OTA_ZIPCODE_CONFIGURATION); else if (!m_isConnectedToFacebook) pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_OTA_FACEBOOK_CONNECT); else SetWizardComplete(true); if (pNextDialog) addCurrentDlgToStack = true; } break; case WINDOW_OTA_ZIPCODE_CONFIGURATION: { pNextDialog = (CGUIDialogBoxeeOTAConnectionConfiguration*)g_windowManager.GetWindow(WINDOW_OTA_CONNECTION_CONFIGURATION); if (pNextDialog) { addCurrentDlgToStack = true; } } break; case WINDOW_OTA_CONNECTION_CONFIGURATION: { if (!m_isConnectedToFacebook) pNextDialog = (CGUIDialogBoxeeWizardBase*)g_windowManager.GetWindow(WINDOW_OTA_FACEBOOK_CONNECT); else SetWizardComplete(true); if (pNextDialog) { addCurrentDlgToStack = true; } } break; case WINDOW_OTA_FACEBOOK_CONNECT: { SetWizardComplete(true); } break; default: { CLog::Log(LOGERROR,"CBoxeeOTAConfigurationManager::HandleNextAction - FAILED to handle WindowId [%d] (digwiz)",id); } break; } if (addCurrentDlgToStack) { AddToStack(id); } else { CLog::Log(LOGDEBUG,"CBoxeeOTAConfigurationManager::HandleNextAction - Not adding [id=%d] to stack. [addCurrentDlgToStack=%d][DialogStackSize=%d] (digwiz)",id,addCurrentDlgToStack,GetStackSize()); } CLog::Log(LOGDEBUG,"CBoxeeOTAConfigurationManager::HandleNextAction - Exit function and return [NextDialog=%p] for [id=%d] (digwiz)",pNextDialog,id); return pNextDialog; }
int ValidateAction(struct message *m, struct mansession *s, int inbound) { char *channel; char *context; char *uchannel; char *ucontext; char *action; char *actionid; char *event; char *response; char *account; char *uniqueid; char *tmp; char *unmatched; char *cheaders[] = {"Channel","Channel1","Channel2","Source","Destination","DestinationChannel","ChannelCalling",NULL}; char *uheaders[] = {"UniqueID","Uniqueid1","Uniqueid2","SrcUniqueId","DestUniqueID",NULL}; int i, cmatched, cfound, ufound; if( debug > 5 ) debugmsg("ValidateAction called for fd: %d, %s", s->fd, inbound?"inbound":"outbound"); if( pc.authrequired && !s->authenticated ) return 0; if( inbound ) // Inbound from server to client ucontext = s->user.icontext; else // Outbound from client to server ucontext = s->user.ocontext; uchannel = s->user.channel; // There is no other filering, so just return quickly. if( uchannel[0] == '\0' && ucontext[0] == '\0' && s->user.account[0] == '\0' && s->user.filter_bits == 0 ) { if( debug > 5 ) debugmsg("Message validated - no filtering"); return 1; } event = astman_get_header(m, "Event"); // If any "FILT" rules fail, then stop processing afterwards. i = 1; // Handle special filter flags before IsInStack checks if( inbound ) { if( s->user.filter_bits & FILT_CDRONLY ) { if( !strcasecmp( event, "CDR" ) ) { if( debug ) debugmsg("CDRONLY set. Is a CDR. Allowed"); return 1; } else { i = 0; } } if( s->user.filter_bits & FILT_BRIONLY ) { if( !strcasecmp( event, "Bridge" ) ) { if( debug ) debugmsg("BRIONLY set. Is a Bridge. Allowed"); return 1; } else { i = 0; } } if( s->user.filter_bits & FILT_XFRONLY ) { if( !strcasecmp( event, "Transfer" ) ) { if( debug ) debugmsg("XFRONLY set. Is a Transfer. Allowed"); return 1; } else { i = 0; } } if( s->user.filter_bits & FILT_NOVAR ) { if( !strcasecmp( event, "SetVar" ) ) { if( debug ) debugmsg("NOVAR set. Blocked SetVar"); return 0; } else if( !strcasecmp( event, "VarSet" ) ) { if( debug ) debugmsg("NOVAR set. Blocked VarSet"); return 0; } } } if( i == 0 ) { if( debug ) debugmsg("FILT_???ONLY rule blocked an event."); return 0; } unmatched = ""; ufound = 0; for( i=0; uheaders[i] != NULL; i++ ) { uniqueid = astman_get_header(m, uheaders[i]); if( uniqueid[0] != '\0' && IsInStack(uniqueid, s) ) { if( debug ) debugmsg("Message validated (%s): %s already allowed", uheaders[i], uniqueid); if( !strcasecmp( event, "Hangup" ) ) DelFromStack(m, s); ufound = 1; } else if( *uniqueid ) { if( debug > 6 ) debugmsg("UniqueID: %s not matched for this connection.", uniqueid); unmatched = uniqueid; } } if( ufound ) { if( *unmatched == '\0' ) { if( debug > 4 ) debugmsg("-- No unmatched header found."); return 1; } if( *uchannel == '\0' ) { if( debug > 4 ) debugmsg("-- chan filtering not enabled."); return 1; } // We are allowing based on UID, but also have an unmatched UID // If Channel matches, then also add that UID. for( i=0; cheaders[i] != NULL; i++ ) { channel = astman_get_header(m, cheaders[i]); if( channel[0] == '\0' ) continue; // No header by that name. if( !strncasecmp( channel, uchannel, strlen(uchannel) )) { // We have a Channel: header, so save the UID if( debug > 4 ) debugmsg("-- Chan match, adding secondary UniqueID: %s", unmatched); return AddToStack(m, s, 0) | 1; } } if( debug > 4 ) debugmsg("-- No Chan match, NOT adding secondary UniqueID: %s", unmatched); return 1; } // Response packets rarely have any of the following fields included, so // we will return a response if the ActionID matches our last known ActionID response = astman_get_header(m, "Response"); actionid = astman_get_header(m, ACTION_ID); if( response[0] != '\0' && actionid[0] != '\0' && !strcmp(actionid, s->actionid) ) { if (s->autofilter < 2 && !strcmp(actionid, s->actionid)) { if( debug > 5 ) debugmsg("Message validated - actionID"); return 1; } else if ( !strncmp(actionid, s->actionid, strlen(s->actionid)) ) { if( debug > 5 ) debugmsg("Message validated - actionID"); return 1; } } action = astman_get_header(m, "Action"); if( uchannel[0] != '\0' ) { if( debug ) debugmsg("Attempting filter using channel: %s", uchannel); cmatched = 0; cfound = 0; for( i=0; cheaders[i] != NULL && !cmatched; i++ ) { channel = astman_get_header(m, cheaders[i]); if( channel[0] == '\0' ) continue; // No header by that name. cfound++; if( !strncasecmp( channel, uchannel, strlen(uchannel) )) { // We have a Channel: header, so filter on it. if( debug > 3 ) debugmsg("Message not filtered (chan): %s due to match", channel); cmatched++; } else if( pc.filterlocal && !inbound && !strcasecmp( action, "Originate" ) && !strcasecmp( channel, "Local/" ) ) { // Exceptions even if we don't match if( pc.filterlocal == 1 ) { // Allow all Local/ channels if( debug > 3 ) debugmsg("Message not filtered (chan): %s due to filterlocal", channel); cmatched++; } else if( pc.filterlocal == 2 ) { // Allow with @ocontext if( !(tmp=strchr(channel, '@')) || strcmp( (tmp+1), ucontext ) ) { // if( debug ) { // debugmsg("Message filtered (chan): %s != %s", channel, uchannel); // debugmsg("filterlocal ->(context): %s != @%s", tmp?tmp:"", ucontext); // } // NOT MATCHED } else { if( debug > 3 ) debugmsg("Message not filtered (chan): %s due to filterlocal", channel); cmatched++; } } else if( pc.filterlocal == 3 ) { // Set @ocontext and allow if( (tmp=strchrnul(channel, '@')) ) { *tmp='@'; strcpy( (tmp+1), ucontext ); if( debug > 3 ) debugmsg("Message not filtered (chan): %s due to filterlocal", channel); cmatched++; } } } } if( cfound && !cmatched ) { if( debug ) debugmsg("Message filtered %d chan headers != %s", cfound, uchannel); return 0; } } context = astman_get_header(m, "Context"); if( context[0] != '\0' && ucontext[0] != '\0' ) { if( strcmp( context, ucontext ) ) { if( debug ) debugmsg("Message filtered (ctxt): %s != %s", context, ucontext); return 0; } } if( s->user.account[0] != '\0' ) { account = astman_get_header(m, "Account"); if( !strcasecmp( action, "Originate" ) ) { if( debug ) debugmsg("Got Originate. Account: %s, setting to: %s", account, s->user.account); if( account[0] == '\0' ) AddHeader(m, "Account: %s", s->user.account); else strcpy(account, s->user.account); } else if( account[0] != '\0' ) { if( debug ) debugmsg("Got Account: %s, setting to: %s", account, s->user.account); strcpy(account, s->user.account); } } // Outbound or unfiltered packets are validated. if( !inbound || (uchannel[0] == '\0' && ucontext[0] == '\0') ) { if( debug > 2 && !inbound ) debugmsg("Validate Passing an outbound message."); if( debug > 2 && (uchannel[0] == '\0' && ucontext[0] == '\0') ) debugmsg("Validate Passing msg with no context or channel filter."); return 1; } int res; res = AddToStack(m, s, 0); if( debug > 5 ) debugmsg("AddToStack returned %d", res); return res; }