/***************************************************************************** ** Procedure: CJTLine::OnLineFeaturesChanged ** ** Arguments: 'dwFeatures' - New features for line ** ** Returns: New features for address ** ** Description: This method overrides the TSP++ library default behavior ** concerning calls placed on an address with active calls ** already present. The default behavior is to not allow ** this situation but in our switch we will automatically ** transition to HOLD so we need to allow it. ** *****************************************************************************/ DWORD CJTLine::OnLineFeaturesChanged (DWORD dwFeatures) { // If this is not a station then let the default behavior take place // in the TSP library. if (GetLineType() == Station) { LPLINEDEVSTATUS pStat = GetLineDevStatus(); LPLINEADDRESSCAPS pACaps = GetAddress(0)->GetAddressCaps(); // Assume we CANNOT place a new call dwFeatures &= ~LINEFEATURE_MAKECALL; // The following must be true in order to place a new outgoing call // at a station on the simulated PBX: // // 1. Line must be INSERVICE and CONNECTED (i.e. agent logged on) // 2. Must have bandwidth for new outgoing call // 3. Agent must NOT be in the READY state. // if (((pStat->dwDevStatusFlags & (LINEDEVSTATUSFLAGS_INSERVICE | LINEDEVSTATUSFLAGS_CONNECTED)) == (LINEDEVSTATUSFLAGS_INSERVICE | LINEDEVSTATUSFLAGS_CONNECTED)) && ((pStat->dwNumActiveCalls + pStat->dwNumOnHoldCalls + pStat->dwNumOnHoldPendCalls) < pACaps->dwMaxNumOnHoldCalls) && (GetAddress(0)->GetAgentStatus()->dwState != LINEAGENTSTATE_READY)) dwFeatures |= LINEFEATURE_MAKECALL; } return CTSPILineConnection::OnLineFeaturesChanged(dwFeatures); }// CJTLine::OnLineFeaturesChanged
bool wxTextFile::OnWrite(wxTextFileType typeNew, const wxMBConv& conv) { wxFileName fn = m_strBufferName; // We do NOT want wxPATH_NORM_CASE here, or the case will not // be preserved. if ( !fn.IsAbsolute() ) fn.Normalize(wxPATH_NORM_ENV_VARS | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE | wxPATH_NORM_LONG); wxTempFile fileTmp(fn.GetFullPath()); if ( !fileTmp.IsOpened() ) { wxLogError(_("can't write buffer '%s' to disk."), m_strBufferName.c_str()); return false; } size_t nCount = GetLineCount(); for ( size_t n = 0; n < nCount; n++ ) { fileTmp.Write(GetLine(n) + GetEOL(typeNew == wxTextFileType_None ? GetLineType(n) : typeNew), conv); } // replace the old file with this one return fileTmp.Commit(); }
/***************************************************************************** ** Procedure: CJTLine::read ** ** Arguments: 'istm' - Input stream ** ** Returns: pointer to istm ** ** Description: This function is called to serialize data in from the ** registry. The line object has already been completely ** initialized by the TSP++ library ** *****************************************************************************/ TStream& CJTLine::read(TStream& istm) { // Adjust the line device capabilities. We don't support any of the // line device capability flags, and don't need dialing parameters since the // switch doesn't allow them to be adjusted. LPLINEDEVCAPS lpCaps = GetLineDevCaps(); lpCaps->dwDevCapFlags = 0; lpCaps->dwUUICallInfoSize = 1024; lpCaps->dwLineStates &= ~(LINEDEVSTATE_RINGING | LINEDEVSTATE_MSGWAITON | LINEDEVSTATE_MSGWAITOFF | LINEDEVSTATE_NUMCOMPLETIONS | LINEDEVSTATE_TERMINALS | LINEDEVSTATE_ROAMMODE | LINEDEVSTATE_BATTERY | LINEDEVSTATE_SIGNAL | LINEDEVSTATE_LOCK | LINEDEVSTATE_COMPLCANCEL | LINEDEVSTATE_MAINTENANCE); // Adjust our address information CTSPIAddressInfo* pAddress = GetAddress(0); _TSP_ASSERTE (pAddress != NULL); LINEADDRESSCAPS* lpACaps = pAddress->GetAddressCaps(); lpACaps->dwMaxCallDataSize = MAXCALLDATA_SIZE; lpACaps->dwCallerIDFlags = lpACaps->dwConnectedIDFlags = lpACaps->dwRedirectionIDFlags = lpACaps->dwRedirectingIDFlags = lpACaps->dwCalledIDFlags = lpACaps->dwCalledIDFlags & ~LINECALLPARTYID_PARTIAL; lpACaps->dwCallStates &= ~(LINECALLSTATE_SPECIALINFO | LINECALLSTATE_RINGBACK); lpACaps->dwDialToneModes &= ~LINEDIALTONEMODE_SPECIAL; lpACaps->dwDisconnectModes &= ~LINEDISCONNECTMODE_REJECT; // Adjust the various line properties based on the type of line this is. if (GetLineType() == Station) InitializeStation(); else if (GetLineType() == RoutePoint) InitializeRoutePoint(); else if (GetLineType() == Queue) InitializeQueue(); else if (GetLineType() == PredictiveDialer) InitializeDialer(); else if (GetLineType() == VRU) InitializeVRU(); // We didn't read any extra information from the stream. return CTSPILineConnection::read(istm); }// CJTLine::read
nsresult nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream, PRInt64 aParent, PRInt64 aToolbar, nsINavBookmarksService* aBMS) { nsresult rv; PRBool moreData = PR_FALSE; nsAutoString buffer; EntryType entryType = EntryType_BOOKMARK; nsAutoString keyword, description; nsCAutoString url, name; PRBool onToolbar = PR_FALSE; do { nsCAutoString cBuffer; rv = aStream->ReadLine(cBuffer, &moreData); if (NS_FAILED(rv)) return rv; CopyUTF8toUTF16(cBuffer, buffer); nsString data; LineType type = GetLineType(buffer, getter_Copies(data)); switch(type) { case LineType_FOLDER: entryType = EntryType_FOLDER; break; case LineType_BOOKMARK: entryType = EntryType_BOOKMARK; break; case LineType_SEPARATOR: // If we're here, we need to break out of the loop for the current folder, // essentially terminating this instance of ParseBookmarksFolder and return // to the calling function, which is either ParseBookmarksFolder for a parent // folder, or CopyBookmarks (which means we're done parsing all bookmarks). goto done; case LineType_NAME: name.Assign(NS_ConvertUTF16toUTF8(data)); break; case LineType_URL: url.Assign(NS_ConvertUTF16toUTF8(data)); break; case LineType_KEYWORD: keyword = data; break; case LineType_DESCRIPTION: description = data; break; case LineType_ONTOOLBAR: if (NS_LITERAL_STRING("YES").Equals(data)) onToolbar = PR_TRUE; break; case LineType_NL: { // XXX We don't know for sure how Opera deals with IDN hostnames in URL. // Assuming it's in UTF-8 is rather safe because it covers two cases // (UTF-8 and ASCII) out of three cases (the last is a non-UTF-8 // multibyte encoding). // XXX Todo: |description| is not saved. if (entryType == EntryType_BOOKMARK) { if (!name.IsEmpty() && !url.IsEmpty()) { nsCOMPtr<nsIURI> uri; rv = NS_NewURI(getter_AddRefs(uri), url); if (NS_FAILED(rv)) continue; PRInt64 id; rv = aBMS->InsertBookmark(onToolbar ? aToolbar : aParent, uri, nsINavBookmarksService::DEFAULT_INDEX, name, &id); if (NS_FAILED(rv)) continue; name.Truncate(); url.Truncate(); keyword.Truncate(); description.Truncate(); onToolbar = PR_FALSE; } } else if (entryType == EntryType_FOLDER) { if (!name.IsEmpty()) { PRInt64 newFolder; rv = aBMS->CreateFolder(onToolbar ? aToolbar : aParent, name, nsINavBookmarksService::DEFAULT_INDEX, &newFolder); if (NS_FAILED(rv)) continue; rv = ParseBookmarksFolder(aStream, newFolder, aToolbar, aBMS); name.Truncate(); } } break; } case LineType_OTHER: break; } } while (moreData); done: return rv; }
static PVIEWERLINE SegmentText(PVIEWERPARAMS pViewerParams, char *pchText, BOOL bHighlight) { PVIEWERLINE pFirstSeg=NULL, pCurrentSeg=NULL; VIEWERLINE LineSeg; char *pchTemp = pchText; ULONG ulLen=0; BOOL bTest=TRUE; ULONG ulType=0; if (!pchText) return NULL; LineSeg.pchLine = pchText; LineSeg.ulLineLen = 0; while (*pchTemp) { if (bTest) { ulType = GetLineType(pViewerParams, pchTemp); bTest = FALSE; } switch(*pchTemp) { case '_': case '*': case '/': if (bHighlight) { ulLen = QuerySegment(pchText, pchTemp); if (ulLen) { /* Altes Segment */ if (LineSeg.ulLineLen) { LineSeg.ulFlags = ulType; pCurrentSeg = AddSegment(pCurrentSeg, &LineSeg); if (!pFirstSeg) pFirstSeg = pCurrentSeg; } /* neues Segment */ LineSeg.ulFlags = ulType; LineSeg.ulLineLen = ulLen; LineSeg.pchLine = pchTemp+1; switch(*pchTemp) { case '_': LineSeg.ulFlags |= LINESEG_UNDER; break; case '/': LineSeg.ulFlags |= LINESEG_ITALIC; break; default: LineSeg.ulFlags |= LINESEG_BOLD; break; } pCurrentSeg = AddSegment(pCurrentSeg, &LineSeg); if (!pFirstSeg) pFirstSeg = pCurrentSeg; /* naechstes Segment */ pchTemp += 1+ulLen; LineSeg.pchLine = pchTemp+1; LineSeg.ulLineLen = 0; LineSeg.ulFlags = ulType; } else LineSeg.ulLineLen++; } else LineSeg.ulLineLen++; break; case '\n': LineSeg.ulFlags = LINESEG_NEWLINE | ulType; pCurrentSeg = AddSegment(pCurrentSeg, &LineSeg); if (!pFirstSeg) pFirstSeg = pCurrentSeg; LineSeg.pchLine = pchTemp+1; LineSeg.ulLineLen = 0; bTest=TRUE; break; default: LineSeg.ulLineLen++; break; } pchTemp++; } if (LineSeg.ulLineLen) { /* letztes Segment noch hinzuf�gen */ LineSeg.ulFlags = LINESEG_NEWLINE | ulType; pCurrentSeg = AddSegment(pCurrentSeg, &LineSeg); if (!pFirstSeg) pFirstSeg = pCurrentSeg; } if (pCurrentSeg) /* sicherstellen, da� letztes Segment das Zeilenende-Flag hat. Kann vor- kommen, wenn letztes Segment ein fettes oder unterstrichenes Segment war */ pCurrentSeg->ulFlags |= LINESEG_NEWLINE; return pFirstSeg; }