/* * Removes the context from the context list * Notifies all its children */ void XP_RemoveContextFromList(MWContext *context) { int howMany; int i; if (context == NULL) return; cx_RemoveChildContext(context); /* Its parent does not point to it any more */ /* Now take care of the children, this should not really happen */ if (context->grid_children) { howMany = XP_ListCount(context->grid_children); for (i = 1; i <= howMany; i++) { MWContext * child; child = (MWContext *)XP_ListGetObjectNum(context->grid_children, 1); if (child) child->grid_parent = NULL; XP_ListRemoveObject(context->grid_children, child); } XP_ListDestroy(context->grid_children); context->grid_children = NULL; } XP_ListRemoveObject(xp_GlobalContextList, context); /* Remove from last active stack. * Remove any nav center info about the context. */ XP_RemoveContextFromLastActiveStack(context); XP_RemoveNavCenterInfo(context); }
/* XP_InterruptContext * interrupts this context, and all the grid cells it encloses */ void XP_InterruptContext(MWContext * context) { int i = 1; MWContext * child; if (context == NULL) return; /* Interrupt the children recursively first. * This avoids the scenario where the context is destroyed during * an interrupt and we end up dereferencing a freed context. * This also avoids crazy hacks like caching the grid_children * context list until after the interrupt, and then doing the * below loop. That can also crash if the grid_children context * list is freed off.... * Bug fix 58770 */ while(child = (MWContext *)XP_ListGetObjectNum(context->grid_children, i++)) XP_InterruptContext(child); NET_InterruptWindow(context); if (context->img_cx) IL_InterruptContext(context->img_cx); ET_InterruptContext(context); }
/* * Finds a context that should be loaded with the URL, given * a type and current (refering) context. Return NULL if there is none. */ MWContext * XP_FindContextOfType (MWContext * context, MWContextType type) { int i; /* The other types aren't "real" - they don't have windows. (Actually, neither do all of these, but it's damned useful to be able to find the biff context...) */ XP_ASSERT (type == MWContextBrowser || type == MWContextMail || type == MWContextNews || type == MWContextMessageComposition || type == MWContextBookmarks || type == MWContextAddressBook || type == MWContextBiff || type == MWContextMailMsg || type == MWContextNewsMsg || type == MWContextEditor || type == MWContextPane); /* Added MWContextEditor, needed for bug 61630 */ /* If our current context has the right type, go there */ if (context && context->type == type) return context; /* otherwise, just get any other context */ for (i=1; i<= XP_ListCount(xp_GlobalContextList); i++) { MWContext * compContext = (MWContext *)XP_ListGetObjectNum(xp_GlobalContextList, i); if (compContext->type == type) return compContext; } return NULL; }
void XFE_ABDirListView::doubleClickBody(const OutlineButtonFuncData *data) { #if defined(USE_ABCOM) int count = 0; const int *indices = 0; m_outliner->getSelection(&indices, &count); int error = AB_CommandAB2(m_pane, AB_PropertiesCmd, (MSG_ViewIndex *) indices, (int32) count); #else /* get dir */ DIR_Server *dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, data->row+1); fe_showABDirPropertyDlg(getToplevel()->getBaseWidget(), m_contextData, dir, &(XFE_ABDirListView::propertyCallback), this); #endif /* USE_ABCOM */ }
MWContext* xp_FindNamedContextInChildren(MWContext* self, char* name, MWContext* excludeChild) { int i; /* XP_TRACE(("Searching for %s: context %0x, name=%s, title=%s\n", (name ? name : ""), self, (self->name ? self->name : ""), (self->title ? self->title : ""))); */ if (self->name && XP_STRCMP(self->name, name) == 0) { /* XP_TRACE(("Found %s context %0x name=%s\n", (name ? name : ""), self, self->name)); */ return self; } if (self->grid_children) { int count = XP_ListCount(self->grid_children); for (i = 1; i <= count; i++) { MWContext* child = (MWContext*)XP_ListGetObjectNum(self->grid_children, i); if (child != excludeChild) { MWContext* found = xp_FindNamedContextInChildren(child, name, NULL); if (found) return found; } } } return NULL; }
fe_icon_data* XFE_ABDirListView::GetDragIconData(int row, int column) { D(("XFE_ABDirListView::GetDragIconData()\n")); /* TODO: get line data * determine entry type * return MNC_AddressSmall, or MN_FolderServer */ fe_icon_data *icon_data = 0; if (row < 0) { #if defined(DEBUG_tao) printf("\n XFE_ABDirListView::GetDragIconData (row,col)=(%d,%d)\n", row, column); #endif }/* if */ else { DIR_Server *dirLine = (DIR_Server *) XP_ListGetObjectNum(m_directories, row+1); if (!dirLine) return icon_data; if (dirLine->dirType == PABDirectory) icon_data = &MNC_AddressSmall; /* shall call make/initialize icons */ else icon_data = &MN_FolderServer; }/* else */ return icon_data; }
void XFE_FrameListMenu::item_activate(Widget item) { XP_ASSERT( XfeIsAlive(m_submenu) ); int i = XfeChildGetIndex(item) - m_firstslot; XP_ASSERT( i > 0 ); if (i <= 0) { return; } XP_List * frame_list = getShownFrames(); XFE_Frame * frame = (XFE_Frame *) XP_ListGetObjectNum(frame_list,i); XP_ASSERT( frame != NULL ); if (frame) { frame->show(); } XmUpdateDisplay(frame->getBaseWidget()); if (frame_list) { XP_ListDestroy(frame_list); } }
/* XP_RefreshAnchors * call it after loading a new URL to refresh all the anchors */ void XP_RefreshAnchors() { int i; for (i=1; i<= XP_ListCount(xp_GlobalContextList); i++) { MWContext * compContext = (MWContext *)XP_ListGetObjectNum(xp_GlobalContextList, i); LO_RefreshAnchors(compContext); } }
/* Backend is not calling FE_PaneChanged on Ldap Directory change right now, therefore, this method is not in use. However, the backend should really call FE_PaneChanged when directory order is changed in the prefs. That notification is hooked up for address book not for ldap search. Has filed a bug to phil */ void XFE_LdapSearchView::paneChanged(XP_Bool /*asynchronous*/, MSG_PANE_CHANGED_NOTIFY_CODE /* notify_code */, int32 /*value*/) { /* Shall we free existing list ? */ m_directories = FE_GetDirServers(); int nDirs = XP_ListCount(m_directories); XP_Bool found = False; for (int i=0; i < nDirs; i++) { DIR_Server *dir = (DIR_Server *) XP_ListGetObjectNum(m_directories,i+1); if (dir == m_dir || (dir && m_dir && (dir->dirType == m_dir->dirType))) { if ((dir->serverName==NULL && m_dir->serverName==NULL) || (dir->serverName && m_dir->serverName && !XP_STRCMP(dir->serverName, m_dir->serverName))) { found = True; break; }/* if */ }/* if */ }/* for i*/ if (!found) { /* m_dir got deleted */ m_dir = NULL; if ( !m_dir && nDirs ) { /* there are still some directories installed, pick the first one for best guess */ m_dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, 1 ); } } if (!m_dir) /* non-directory left.... close search dialog*/ handleClose(); }
void XFE_LdapSearchView::initialize() { // LDAP Specific m_rules.scope = (MSG_ScopeAttribute)scopeLdapDirectory; m_toAddrBook = NULL; m_toCompose = NULL; m_browserFrame = NULL; m_directories = FE_GetDirServers(); int nDirs = XP_ListCount(m_directories); if ( nDirs ) m_dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, 1); else m_dir = NULL; }
void XFE_ABDirListView::propertiesCB() { int count = 0; const int *indices = 0; m_outliner->getSelection(&indices, &count); if (count > 0 && indices) { DIR_Server *dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, indices[0]+1); fe_showABDirPropertyDlg(getToplevel()->getBaseWidget(), m_contextData, dir, &(XFE_ABDirListView::propertyCallback), this); }/* if */ }
void XFE_ABDirListView::propertyCB(DIR_Server *dir) { int which = XP_ListGetNumFromObject(m_directories, dir); #if defined(DEBUG_tao) printf("\nXFE_ABDirListView::propertyCB=%d\n", which); #endif if (!which) { /* new */ const int *selected; int count; m_outliner->getSelection(&selected, &count); int pos = 0; if (m_nDirs > 0 && count && selected) { // Insert dir at position pos = selected[0]; DIR_Server *prev_dir; prev_dir = (DIR_Server*)XP_ListGetObjectNum(m_directories, pos+1); XP_ListInsertObjectAfter(m_directories, prev_dir, dir); pos = pos+1; } else { XP_ListAddObjectToEnd(m_directories, dir); pos = m_nDirs+1; } // Repaint m_nDirs = XP_ListCount(m_directories); m_outliner->change(0, m_nDirs, m_nDirs); // Set selection m_outliner->selectItemExclusive(pos); notifyInterested(XFE_ABDirListView::dirSelect, (void *) dir); }/* if */ else m_outliner->invalidateLine(which); DIR_SaveServerPreferences(m_directories); if (m_deleted_directories) { DIR_CleanUpServerPreferences(m_deleted_directories); m_deleted_directories = NULL; }/* if */ getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating); }
DIR_Server* XFE_LdapSearchView::getDirServer() { Widget btn; int folderNum; XtVaGetValues(m_rules.scopeOptW, XmNmenuHistory, &btn, 0 ); XtVaGetValues(btn, XmNuserData, &folderNum, 0); // Ldap search start ... if ( m_numsubviews <= 0 ) return 0; // This should never happen int nDirs = XP_ListCount(m_directories); DIR_Server *dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, folderNum+1); m_dir = dir; return dir; }
Bool XP_IsContextBusy(MWContext * context) { int i = 1; MWContext * child; if (context == NULL) return FALSE; if (NET_AreThereActiveConnectionsForWindow(context)) return TRUE; while ((child = (MWContext*)XP_ListGetObjectNum (context->grid_children, i++))) if (XP_IsContextBusy(child)) return TRUE; return FALSE; }
uint32 lm_FindEventInMWContext(MWContext *context) { int i; XP_List *kids; MWContext *kid; uint32 events; if (!context->grid_children) return context->event_bit; events = 0; if ((kids = context->grid_children) != NULL) { for (i = 1; ((kid = XP_ListGetObjectNum(kids, i)) != NULL); i++) { events |= lm_FindEventInMWContext(kid); } } return events; }
// Override void XFE_LdapSearchView::addDefaultFolders() { int i; Widget popupW; Cardinal ac = 0; Arg av[10]; XP_List *directories = FE_GetDirServers(); int nDirs = XP_ListCount(directories); XtVaGetValues(m_rules.scopeOptW, XmNsubMenuId, &popupW, 0); /* Hopefully: Get Number of Scope Names from MSG */ for ( i = 0; i < nDirs; i++) { Widget btn; XmString xmStr; DIR_Server *dir = (DIR_Server*)XP_ListGetObjectNum(directories,i+1); if ( dir && dir->dirType == LDAPDirectory ) { xmStr = XmStringCreateLtoR(dir->description, XmSTRING_DEFAULT_CHARSET); ac = 0; XtSetArg(av[ac], XmNuserData, i); ac++; XtSetArg(av[ac], XmNlabelString, xmStr); ac++; btn = XmCreatePushButtonGadget(popupW, "ldapDirectory", av, ac); XtAddCallback(btn, XmNactivateCallback, XFE_LdapSearchView::folderOptionCallback, this); XtManageChild(btn); XmStringFree(xmStr); } } }
/* the following was adapted from xp_FindNamedContextInChildren, but simplified for simply matching pointers instead of names. */ Bool XP_IsChildContext(MWContext* parent, MWContext* child) { int i; if (parent == child) { return TRUE; } if (parent->grid_children) { int count = XP_ListCount(parent->grid_children); for (i = 1; i <= count; i++) { MWContext* tchild = (MWContext*)XP_ListGetObjectNum(parent->grid_children, i); if (child == tchild) { return TRUE; } else{ XP_Bool found = XP_IsChildContext(tchild, child); if (found) return found; } } } return FALSE; }
void XFE_ABDirListView::selectLine(int line) { #if defined(USE_ABCOM) AB_ContainerAttribValue *value = NULL; int error = AB_GetContainerAttributeForPane(m_pane, line, attribContainerInfo, &value); XP_ASSERT(value && value->attrib == attribContainerInfo && value->u.container); // set active one m_activeContainer = value->u.container; notifyInterested(XFE_ABDirListView::dirSelect, (void *) value->u.container); AB_FreeContainerAttribValue(value); #else DIR_Server *dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, line+1); selectDir(dir); #endif /* USE_ABCOM */ }
/* * Count the contexts of the said type. * The second parameter is a flag indicating wether or not the contexts * counted can have parent contexts (top level context switch). */ int XP_ContextCount(MWContextType cxType, XP_Bool bTopLevel) { int iRetval = 0; int iTraverse; MWContext *pContext; /* * Loop through the contexts. */ for(iTraverse = 1; iTraverse <= XP_ListCount(xp_GlobalContextList); iTraverse++) { pContext = (MWContext *)XP_ListGetObjectNum(xp_GlobalContextList, iTraverse); if(cxType == MWContextAny || pContext->type == cxType) { /* * See if there's to be no parent. */ if(bTopLevel == FALSE || pContext->is_grid_cell == FALSE) { iRetval++; } } } return(iRetval); }
void *XFE_ABDirListView::acquireLineData(int line) { #if defined(USE_ABCOM) if (line < 0 || !m_outliner || line >= m_outliner->getTotalLines()) return 0; AB_ContainerAttribValue *value = NULL; int error = AB_GetContainerAttributeForPane(m_pane, line, attribContainerInfo, &value); XP_ASSERT(value && value->attrib == attribContainerInfo && value->u.container); m_containerLine = value->u.container; AB_FreeContainerAttribValue(value); /* ancestor */ /* depth */ error = AB_GetContainerAttribute(m_containerLine, attribDepth, &value); XP_ASSERT(value && value->attrib == attribDepth); int32 depth = value->u.number; #if defined(DEBUG_tao_) printf("\nXFE_ABDirListView::acquireLineData, depth=%d\n", depth); #endif AB_FreeContainerAttribValue(value); if (depth) m_ancestorInfo = new OutlinerAncestorInfo[depth]; else m_ancestorInfo = new OutlinerAncestorInfo[1]; // ripped straight from the winfe int i = depth - 1; int idx = line + 1; int total_lines = m_outliner->getTotalLines(); while (i > 0) { if ( idx < total_lines ) { /* depth */ error = AB_GetContainerAttribute(m_containerLine, attribDepth, &value); XP_ASSERT(value && value->attrib == attribDepth); int32 level = value->u.number; AB_FreeContainerAttribValue(value); if ( (level - 1) == i ) { m_ancestorInfo[i].has_prev = TRUE; m_ancestorInfo[i].has_next = TRUE; i--; idx++; }/* if */ else if ( (level - 1) < i ) { m_ancestorInfo[i].has_prev = FALSE; m_ancestorInfo[i].has_next = FALSE; i--; }/* else if */ else { idx++; }/* else */ }/* if */ else { m_ancestorInfo[i].has_prev = FALSE; m_ancestorInfo[i].has_next = FALSE; i--; }/* else */ }/* while */ m_ancestorInfo[0].has_prev = FALSE; m_ancestorInfo[0].has_next = FALSE; return m_containerLine; #else if (line < 0 || line >= m_nDirs || m_directories == 0) { m_dirLine = 0; return 0; }/* if */ else { m_dirLine = (DIR_Server *) XP_ListGetObjectNum(m_directories, line+1); }/* else */ /* ancestor */ m_ancestorInfo = NULL; int level = (m_dirLine->dirType == PABDirectory)?1:0; if (level > 0) { m_ancestorInfo = new OutlinerAncestorInfo[level]; } else { m_ancestorInfo = new OutlinerAncestorInfo[ 1 ]; } // ripped straight from the winfe int i = level - 1; int idx = line + 1; int total_lines = m_outliner->getTotalLines(); while ( i > 0 ) { if ( idx < total_lines ) { int level = (m_dirLine->dirType == PABDirectory)?1:2; //MSG_GetFolderLevelByIndex(m_pane, idx); if ( (level - 1) == i ) { m_ancestorInfo[i].has_prev = TRUE; m_ancestorInfo[i].has_next = TRUE; i--; idx++; } else if ( (level - 1) < i ) { m_ancestorInfo[i].has_prev = FALSE; m_ancestorInfo[i].has_next = FALSE; i--; } else { idx++; } } else { m_ancestorInfo[i].has_prev = FALSE; m_ancestorInfo[i].has_next = FALSE; i--; } } m_ancestorInfo[0].has_prev = FALSE; m_ancestorInfo[0].has_next = FALSE; return m_dirLine; #endif /* !USE_ABCOM */ }
MWContext * XP_FindNamedContextInList(MWContext * context, char *name) { int i; if ((name == NULL) || (xp_GlobalContextList == NULL)) return context; /* * Check for special magic window target names */ if (name[0] == '_') { if (XP_STRNCMP(name, "_self", 5) == 0) { return context; } else if (XP_STRNCMP(name, "_parent", 7) == 0) { if ((context)&&(context->grid_parent)) { return context->grid_parent; } else { return context; } } else if (XP_STRNCMP(name, "_top", 4) == 0) { MWContext *top; top = context; while ((top)&&(top->grid_parent)) { top = top->grid_parent; } return top; } else if (XP_STRNCMP(name, "_blank", 6) == 0) { return NULL; } /* else, search for the name, below */ } { MWContext* cx = context; MWContext* found; if (context) { /* If our current context has the right name, go there */ if (cx->name && (XP_STRCMP(cx->name, name) == 0)) return cx; found = xp_FindNamedContextInChildren(cx, name, NULL); if (found) return found; while (cx->is_grid_cell) { MWContext* parent = cx->grid_parent; found = xp_FindNamedContextInChildren(parent, name, cx); if (found) return found; cx = parent; } } /* otherwise, just get any other context */ for (i=1; i<= XP_ListCount(xp_GlobalContextList); i++) { MWContext* compContext = (MWContext *)XP_ListGetObjectNum(xp_GlobalContextList, i); /* Only search other top-level contexts that aren't the one we just came from: */ if (!compContext->is_grid_cell && compContext != cx) { found = xp_FindNamedContextInChildren(compContext, name, NULL); if (found) return found; } } } return NULL; }
/* * Will return the lowest security status of the context * and it's children. * Lowest means lowest in security, not in numberic value. * * Possible returns are: * SSL_SECURITY_STATUS_NOOPT * SSL_SECURITY_STATUS_OFF * SSL_SECURITY_STATUS_ON_HIGH * SSL_SECURITY_STATUS_ON_LOW */ int XP_GetSecurityStatus(MWContext *pContext) { History_entry *pHistEnt; MWContext *pChild; int iRetval, iIndex; /* * No context, no security. */ if(pContext == NULL) { return(SSL_SECURITY_STATUS_NOOPT); } /* * Obtain the context's current history entry (it holds * security info). */ pHistEnt = SHIST_GetCurrent(&(pContext->hist)); if(pHistEnt == NULL) { /* * Nothing loaded, Confusion ensues here. * If we've a parent context, then our security * is a noopt (shouldn't be counted towards * the whole). * If we've no parent context, then our security * is off. * This allows grids to have empty panes, but to * still be secure if all grids which have * something loaded are secure. */ if(pContext->grid_parent == NULL) { return(SSL_SECURITY_STATUS_OFF); } else { return(SSL_SECURITY_STATUS_NOOPT); } } /* * Our security status. */ iRetval = pHistEnt->security_on; /* * If we're a grid parent, our security status * is a noopt (doesn't affect the whole). * This allows the parent grid document to be non * secure, and all the inner grids to be secure, * and therefore the document should still be * considered secure as a whole. */ if(XP_ListIsEmpty(pContext->grid_children)) { return(iRetval); } iRetval = SSL_SECURITY_STATUS_NOOPT; /* * Go through each child, getting it's security status. * We combine them all and return that value. */ iIndex = 1; while((pChild = (MWContext *)XP_ListGetObjectNum( pContext->grid_children, iIndex++))) { switch(XP_GetSecurityStatus(pChild)) { case SSL_SECURITY_STATUS_NOOPT: /* * No definable security status. Don't * change our current value. */ break; case SSL_SECURITY_STATUS_OFF: /* * No need in continuing if we're turning * off security altogether. */ return(SSL_SECURITY_STATUS_OFF); break; case SSL_SECURITY_STATUS_ON_LOW: /* * Change the return value to lower security. */ iRetval = SSL_SECURITY_STATUS_ON_LOW; break; case SSL_SECURITY_STATUS_ON_HIGH: /* * If we're currently noopt, then we should * change the security status to HIGH. * Otherwise, don't change the cumulative status * which could be lower than HIGH. */ if(iRetval == SSL_SECURITY_STATUS_NOOPT) { iRetval = SSL_SECURITY_STATUS_ON_HIGH; } break; #ifdef FORTEZZA case SSL_SECURITY_STATUS_FORTEZZA: /* * If any fortezza, set to fortezza.. */ iRetval = SSL_SECURITY_STATUS_FORTEZZA; break; #endif default: /* * Shouldn't be here, unless new security status * introduced. */ XP_ASSERT(0); break; } } /* * Context is somewhat secure, either high or low. * This could also be noopt, meaning no definable security, * so turn off your UI as if SSL_SECURITY_STATUS_OFF. * We can't just change the return value of * SSL_SECURITY_STATUS_NOOPT to OFF because this * breaks the recursive correctness of this routine. * Handle it accordingly. */ return(iRetval); }