void MicroDVDSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename, wxString const& encoding) const { agi::vfr::Framerate fps = AskForFPS(true, false); if (!fps.IsLoaded()) return; AssFile copy(*src); copy.Sort(); StripComments(copy.Line); RecombineOverlaps(copy.Line); MergeIdentical(copy.Line); StripTags(copy.Line); ConvertNewlines(copy.Line, "|"); TextFileWriter file(filename, encoding); // Write FPS line if (!fps.IsVFR()) { file.WriteLineToFile(wxString::Format("{1}{1}%.6f", fps.FPS())); } // Write lines for (LineList::const_iterator cur = copy.Line.begin(); cur != copy.Line.end(); ++cur) { if (AssDialogue *current = dynamic_cast<AssDialogue*>(*cur)) { int start = fps.FrameAtTime(current->Start, agi::vfr::START); int end = fps.FrameAtTime(current->End, agi::vfr::END); file.WriteLineToFile(wxString::Format("{%i}{%i}%s", start, end, current->Text)); } } }
void MicroDVDSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const { agi::vfr::Framerate fps = AskForFPS(true, false); if (!fps.IsLoaded()) return; AssFile copy(*src); copy.Sort(); StripComments(copy); RecombineOverlaps(copy); MergeIdentical(copy); StripTags(copy); ConvertNewlines(copy, "|"); TextFileWriter file(filename, encoding); // Write FPS line if (!fps.IsVFR()) file.WriteLineToFile(str(boost::format("{1}{1}%.6f") % fps.FPS())); // Write lines for (auto current : copy.Line | agi::of_type<AssDialogue>()) { int start = fps.FrameAtTime(current->Start, agi::vfr::START); int end = fps.FrameAtTime(current->End, agi::vfr::END); file.WriteLineToFile(str(boost::format("{%i}{%i}%s") % start % end % boost::replace_all_copy(current->Text.get(), "\\N", "|"))); } }
void EncoreSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename, wxString const&) const { agi::vfr::Framerate fps = AskForFPS(false, true); if (!fps.IsLoaded()) return; // Convert to encore AssFile copy(*src); copy.Sort(); StripComments(copy.Line); RecombineOverlaps(copy.Line); MergeIdentical(copy.Line); StripTags(copy.Line); ConvertNewlines(copy.Line, "\r\n"); // Encode wants ; for NTSC and : for PAL // The manual suggests no other frame rates are supported char sep = fps.NeedsDropFrames() ? ';' : ':'; SmpteFormatter ft(fps, sep); // Write lines int i = 0; TextFileWriter file(filename, "UTF-8"); for (LineList::const_iterator cur = copy.Line.begin(); cur != copy.Line.end(); ++cur) { if (AssDialogue *current = dynamic_cast<AssDialogue*>(*cur)) { ++i; file.WriteLineToFile(wxString::Format("%i %s %s %s", i, ft.ToSMPTE(current->Start), ft.ToSMPTE(current->End), current->Text)); } } }
void TTXTSubtitleFormat::ConvertToTTXT(AssFile &file) const { file.Sort(); StripComments(file); RecombineOverlaps(file); MergeIdentical(file); StripTags(file); ConvertNewlines(file, "\r\n"); // Find last line agi::Time lastTime; if (!file.Events.empty()) lastTime = file.Events.back().End; // Insert blank line at the end auto diag = new AssDialogue; diag->Start = lastTime; diag->End = lastTime+OPT_GET("Timing/Default Duration")->GetInt(); file.Events.push_back(*diag); }
void TTXTSubtitleFormat::ConvertToTTXT(AssFile &file) const { file.Sort(); StripComments(file); RecombineOverlaps(file); MergeIdentical(file); StripTags(file); ConvertNewlines(file, "\r\n"); // Find last line AssTime lastTime; for (auto line : file.Line | boost::adaptors::reversed | agi::of_type<AssDialogue>()) { lastTime = line->End; break; } // Insert blank line at the end auto diag = new AssDialogue; diag->Start = lastTime; diag->End = lastTime+OPT_GET("Timing/Default Duration")->GetInt(); file.Line.push_back(*diag); }
void EncoreSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& video_fps, std::string const&) const { agi::vfr::Framerate fps = AskForFPS(false, true, video_fps); if (!fps.IsLoaded()) return; // Convert to encore AssFile copy(*src); copy.Sort(); StripComments(copy); RecombineOverlaps(copy); MergeIdentical(copy); StripTags(copy); ConvertNewlines(copy, "\r\n"); // Encore wants ; for NTSC and : for PAL // The manual suggests no other frame rates are supported SmpteFormatter ft(fps, fps.NeedsDropFrames() ? ";" : ":"); // Write lines int i = 0; TextFileWriter file(filename, "UTF-8"); for (auto const& current : copy.Events) file.WriteLineToFile(str(boost::format("%i %s %s %s") % ++i % ft.ToSMPTE(current.Start) % ft.ToSMPTE(current.End) % current.Text)); }
void TTXTSubtitleFormat::ConvertToTTXT(AssFile &file) const { file.Sort(); StripComments(file.Line); RecombineOverlaps(file.Line); MergeIdentical(file.Line); StripTags(file.Line); ConvertNewlines(file.Line, "\r\n"); // Find last line AssTime lastTime; for (LineList::reverse_iterator cur = file.Line.rbegin(); cur != file.Line.rend(); ++cur) { if (AssDialogue *prev = dynamic_cast<AssDialogue*>(*cur)) { lastTime = prev->End; break; } } // Insert blank line at the end AssDialogue *diag = new AssDialogue; diag->Start = lastTime; diag->End = lastTime+OPT_GET("Timing/Default Duration")->GetInt(); file.Line.push_back(diag); }
int main(int argc, char* argv[]) { ShowBanner(); if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { cerr << _T("MFC Failed to initialize.\n"); return 1; } if (argc < 2 || !ParseOptions(argc, argv) || pszURL == NULL) ShowUsage(); int nRetCode = 0; CTearSession session(_T("TEAR - MFC Sample App"), dwAccessType); CHttpConnection* pServer = NULL; CHttpFile* pFile = NULL; try { // check to see if this is a reasonable URL CString strServerName; CString strObject; INTERNET_PORT nPort; DWORD dwServiceType; if (!AfxParseURL(pszURL, dwServiceType, strServerName, strObject, nPort) || dwServiceType != INTERNET_SERVICE_HTTP) { cerr << _T("Error: can only use URLs beginning with http://") << endl; ThrowTearException(1); } if (bProgressMode) { cerr << _T("Opening Internet..."); VERIFY(session.EnableStatusCallback(TRUE)); } pServer = session.GetHttpConnection(strServerName, nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject, NULL, 1, NULL, NULL, dwHttpRequestFlags); pFile->AddRequestHeaders(szHeaders); pFile->SendRequest(); DWORD dwRet; pFile->QueryInfoStatusCode(dwRet); // if access was denied, prompt the user for the password if (dwRet == HTTP_STATUS_DENIED) { DWORD dwPrompt; dwPrompt = pFile->ErrorDlg(NULL, ERROR_INTERNET_INCORRECT_PASSWORD, FLAGS_ERROR_UI_FLAGS_GENERATE_DATA | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS, NULL); // if the user cancelled the dialog, bail out if (dwPrompt != ERROR_INTERNET_FORCE_RETRY) { cerr << _T("Access denied: Invalid password\n"); ThrowTearException(1); } pFile->SendRequest(); pFile->QueryInfoStatusCode(dwRet); } CString strNewLocation; pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strNewLocation); // were we redirected? // these response status codes come from WININET.H if (dwRet == HTTP_STATUS_MOVED || dwRet == HTTP_STATUS_REDIRECT || dwRet == HTTP_STATUS_REDIRECT_METHOD) { CString strNewLocation; pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strNewLocation); int nPlace = strNewLocation.Find(_T("Location: ")); if (nPlace == -1) { cerr << _T("Error: Site redirects with no new location") << endl; ThrowTearException(2); } strNewLocation = strNewLocation.Mid(nPlace + 10); nPlace = strNewLocation.Find('\n'); if (nPlace > 0) strNewLocation = strNewLocation.Left(nPlace); // close up the redirected site pFile->Close(); delete pFile; pServer->Close(); delete pServer; if (bProgressMode) { cerr << _T("Caution: redirected to "); cerr << (LPCTSTR) strNewLocation << endl; } // figure out what the old place was if (!AfxParseURL(strNewLocation, dwServiceType, strServerName, strObject, nPort)) { cerr << _T("Error: the redirected URL could not be parsed.") << endl; ThrowTearException(2); } if (dwServiceType != INTERNET_SERVICE_HTTP) { cerr << _T("Error: the redirected URL does not reference a HTTP resource.") << endl; ThrowTearException(2); } // try again at the new location pServer = session.GetHttpConnection(strServerName, nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject, NULL, 1, NULL, NULL, dwHttpRequestFlags); pFile->AddRequestHeaders(szHeaders); pFile->SendRequest(); pFile->QueryInfoStatusCode(dwRet); if (dwRet != HTTP_STATUS_OK) { cerr << _T("Error: Got status code ") << dwRet << endl; ThrowTearException(2); } } cerr << _T("Status Code is ") << dwRet << endl; TCHAR sz[1024]; while (pFile->ReadString(sz, 1023)) { if (bStripMode) StripTags(sz); cout << sz; } // NOTE: Since HTTP servers normally spit back plain text, the // above code (which reads line by line) is just fine. However, // other data sources (eg, FTP servers) might provide binary data // which should be handled a buffer at a time, like this: #if 0 while (nRead > 0) { sz[nRead] = '\0'; if (bStripMode) StripTags(sz); cout << sz; nRead = pFile->Read(sz, 1023); } #endif pFile->Close(); pServer->Close(); } catch (CInternetException* pEx) { // catch errors from WinINet TCHAR szErr[1024]; pEx->GetErrorMessage(szErr, 1024); cerr << _T("Error: (") << pEx->m_dwError << _T(") "); cerr << szErr << endl; nRetCode = 2; pEx->Delete(); } catch (CTearException* pEx) { // catch things wrong with parameters, etc nRetCode = pEx->m_nErrorCode; TRACE1("Error: Exiting with CTearException(%d)\n", nRetCode); pEx->Delete(); } if (pFile != NULL) delete pFile; if (pServer != NULL) delete pServer; session.Close(); return nRetCode; }
/***************************************************************************** * ParseText: parse an text subtitle packet and send it to the video output *****************************************************************************/ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block ) { decoder_sys_t *p_sys = p_dec->p_sys; subpicture_t *p_spu = NULL; char *psz_subtitle = NULL; video_format_t fmt; /* We cannot display a subpicture with no date */ if( p_block->i_pts == 0 ) { msg_Warn( p_dec, "subtitle without a date" ); return NULL; } /* Check validity of packet data */ /* An "empty" line containing only \0 can be used to force and ephemer picture from the screen */ if( p_block->i_buffer < 1 ) { msg_Warn( p_dec, "no subtitle data" ); return NULL; } /* Should be resiliant against bad subtitles */ psz_subtitle = strndup( (const char *)p_block->p_buffer, p_block->i_buffer ); if( psz_subtitle == NULL ) return NULL; if( p_sys->iconv_handle == (vlc_iconv_t)-1 ) EnsureUTF8( psz_subtitle ); else { if( p_sys->b_autodetect_utf8 ) { if( IsUTF8( psz_subtitle ) == NULL ) { msg_Dbg( p_dec, "invalid UTF-8 sequence: " "disabling UTF-8 subtitles autodetection" ); p_sys->b_autodetect_utf8 = VLC_FALSE; } } if( !p_sys->b_autodetect_utf8 ) { size_t inbytes_left = strlen( psz_subtitle ); size_t outbytes_left = 6 * inbytes_left; char *psz_new_subtitle = malloc( outbytes_left + 1 ); char *psz_convert_buffer_out = psz_new_subtitle; const char *psz_convert_buffer_in = psz_subtitle; size_t ret = vlc_iconv( p_sys->iconv_handle, &psz_convert_buffer_in, &inbytes_left, &psz_convert_buffer_out, &outbytes_left ); *psz_convert_buffer_out++ = '\0'; free( psz_subtitle ); if( ( ret == (size_t)(-1) ) || inbytes_left ) { free( psz_new_subtitle ); msg_Err( p_dec, _("failed to convert subtitle encoding.\n" "Try manually setting a character-encoding " "before you open the file.") ); return NULL; } psz_subtitle = realloc( psz_new_subtitle, psz_convert_buffer_out - psz_new_subtitle ); } } /* Create the subpicture unit */ p_spu = p_dec->pf_spu_buffer_new( p_dec ); if( !p_spu ) { msg_Warn( p_dec, "can't get spu buffer" ); if( psz_subtitle ) free( psz_subtitle ); return NULL; } p_spu->b_pausable = VLC_TRUE; /* Create a new subpicture region */ memset( &fmt, 0, sizeof(video_format_t) ); fmt.i_chroma = VLC_FOURCC('T','E','X','T'); fmt.i_aspect = 0; fmt.i_width = fmt.i_height = 0; fmt.i_x_offset = fmt.i_y_offset = 0; p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_dec), &fmt ); if( !p_spu->p_region ) { msg_Err( p_dec, "cannot allocate SPU region" ); if( psz_subtitle ) free( psz_subtitle ); p_dec->pf_spu_buffer_del( p_dec, p_spu ); return NULL; } /* Decode and format the subpicture unit */ if( p_dec->fmt_in.i_codec != VLC_FOURCC('s','s','a',' ') ) { /* Normal text subs, easy markup */ p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; p_spu->i_x = p_sys->i_align ? 20 : 0; p_spu->i_y = 10; /* Remove formatting from string */ StripTags( psz_subtitle ); p_spu->p_region->psz_text = psz_subtitle; p_spu->i_start = p_block->i_pts; p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->b_ephemer = (p_block->i_length == 0); p_spu->b_absolute = VLC_FALSE; } else { /* Decode SSA strings */ ParseSSAString( p_dec, psz_subtitle, p_spu ); p_spu->i_start = p_block->i_pts; p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->b_ephemer = (p_block->i_length == 0); p_spu->b_absolute = VLC_FALSE; p_spu->i_original_picture_width = p_sys->i_original_width; p_spu->i_original_picture_height = p_sys->i_original_height; if( psz_subtitle ) free( psz_subtitle ); } return p_spu; }
/***************************************************************************** * ParseText: parse an text subtitle packet and send it to the video output *****************************************************************************/ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block ) { decoder_sys_t *p_sys = p_dec->p_sys; subpicture_t *p_spu = NULL; char *psz_subtitle = NULL; /* We cannot display a subpicture with no date */ if( p_block->i_pts <= VLC_TS_INVALID ) { msg_Warn( p_dec, "subtitle without a date" ); return NULL; } /* Check validity of packet data */ /* An "empty" line containing only \0 can be used to force and ephemer picture from the screen */ if( p_block->i_buffer < 1 ) { msg_Warn( p_dec, "no subtitle data" ); return NULL; } /* Should be resiliant against bad subtitles */ psz_subtitle = malloc( p_block->i_buffer + 1 ); if( psz_subtitle == NULL ) return NULL; memcpy( psz_subtitle, p_block->p_buffer, p_block->i_buffer ); psz_subtitle[p_block->i_buffer] = '\0'; if( p_sys->iconv_handle == (vlc_iconv_t)-1 ) { if (EnsureUTF8( psz_subtitle ) == NULL) { msg_Err( p_dec, "failed to convert subtitle encoding.\n" "Try manually setting a character-encoding " "before you open the file." ); } } else { if( p_sys->b_autodetect_utf8 ) { if( IsUTF8( psz_subtitle ) == NULL ) { msg_Dbg( p_dec, "invalid UTF-8 sequence: " "disabling UTF-8 subtitles autodetection" ); p_sys->b_autodetect_utf8 = false; } } if( !p_sys->b_autodetect_utf8 ) { size_t inbytes_left = strlen( psz_subtitle ); size_t outbytes_left = 6 * inbytes_left; char *psz_new_subtitle = xmalloc( outbytes_left + 1 ); char *psz_convert_buffer_out = psz_new_subtitle; const char *psz_convert_buffer_in = psz_subtitle; size_t ret = vlc_iconv( p_sys->iconv_handle, &psz_convert_buffer_in, &inbytes_left, &psz_convert_buffer_out, &outbytes_left ); *psz_convert_buffer_out++ = '\0'; free( psz_subtitle ); if( ( ret == (size_t)(-1) ) || inbytes_left ) { free( psz_new_subtitle ); msg_Err( p_dec, "failed to convert subtitle encoding.\n" "Try manually setting a character-encoding " "before you open the file." ); return NULL; } psz_subtitle = realloc( psz_new_subtitle, psz_convert_buffer_out - psz_new_subtitle ); if( !psz_subtitle ) psz_subtitle = psz_new_subtitle; } } /* Create the subpicture unit */ p_spu = decoder_NewSubpictureText( p_dec ); if( !p_spu ) { free( psz_subtitle ); return NULL; } p_spu->i_start = p_block->i_pts; p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->b_ephemer = (p_block->i_length == 0); p_spu->b_absolute = false; subpicture_updater_sys_t *p_spu_sys = p_spu->updater.p_sys; p_spu_sys->align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; p_spu_sys->text = StripTags( psz_subtitle ); if( var_InheritBool( p_dec, "subsdec-formatted" ) ) p_spu_sys->html = CreateHtmlSubtitle( &p_spu_sys->align, psz_subtitle ); free( psz_subtitle ); return p_spu; }
BOOL CNetRssProtocol::SendNet_StatusExch(const char* szRec,const char* szProtocol) { if(CString(szProtocol)=="sms"){ return 1; } if(objSettings.lRSSLocUser){ if(isScreenSaverActiveOrCLocked()){ return -1; } } CString szRecipient=GetCompNameNoProtocol(szRec); int iPerson=objSettings.AddrBook.FindPersonByIP(szRecipient,TRUE); if(iPerson!=-1){ if(objSettings.AddrBook.aPersons[iPerson]->IsGroup()){ // Групповой-заблокирован return -1; }; } CWebWorld url; CString sRSS=url.GetWebPage(szRecipient); if(sRSS==""){ // Не доступен return -1; } #ifdef _DEBUG CString sFile=CString("lastblog")+szRecipient+".xml";//http://davydov.blogspot.com/atom.xml MakeSafeFileName(sFile); SaveFile(CString("c://")+sFile,sRSS); #endif int iStatus=1; XDoc* feedDoc=parseXML(sRSS); XNode* feed=0; if(feedDoc){ feed=feedDoc->GetRoot(); if(!feed){ delete feedDoc; return -1; } CString sLnewsBuildDate=aLoadedRss[szRecipient]; int iMaxNews=objSettings.dwProtocolRSSMAxNews; if(sLnewsBuildDate==""){ iMaxNews=5; } CString sLnewsBuildDateToSet=""; BOOL bAtom=0; CString sGlobalTitle; if(feed->GetChild("channel",1)==GetEmptyNode() && feed->GetChild("title",1)!=GetEmptyNode()){ // Atom!!! bAtom=1; sGlobalTitle=feed->GetChild("title",1)->value; }else{ sGlobalTitle=feed->GetChild("channel",1)->GetChild("title",1)->value; } CString sFrom=""; if(iPerson!=-1){ sFrom=objSettings.AddrBook.aPersons[iPerson]->GetTitle(); }else{ sFrom=sGlobalTitle+"/rss"; } CXMLNodes feedItems; if(bAtom){ feed->FindByTagName("entry",FALSE,feedItems); }else{ feed->GetChild("channel",1)->FindByTagName("item",FALSE,feedItems); } int iCount=0; int iLenCount=feedItems.GetSize(); if(iLenCount==0){ // Может rdf??? feed->FindByTagName("item",FALSE,feedItems); iLenCount=feedItems.GetSize(); } CString sSummary; while(iCount<iLenCount && iCount<iMaxNews){ XNode* item=feedItems[iCount]; CString sPubDate; if(bAtom){ sPubDate=item->GetChild("issued",1)->value; }else{ sPubDate=item->GetChild("pubDate",1)->value; if(sPubDate==""){ //rdf??? sPubDate=item->GetChild("dc:date",1)->value; } } //sPubDate=UnescapeString(sPubDate); StripTags(sPubDate); DeEntitize(sPubDate); CString sTitle; sTitle=item->GetChild("title",1)->value; //sTitle=UnescapeString(sTitle); StripTags(sTitle); DeEntitize(sTitle); if(sTitle==""){ sTitle=sGlobalTitle; } CString sAuthor; if(bAtom){ LPXNode pAut; pAut=item->GetChild("author",1); if(pAut->iBeginPos!=-1 && pAut->iEndPos!=-1){ sAuthor=sRSS.Mid(pAut->iBeginPos,pAut->iEndPos-pAut->iBeginPos); } }else{ sAuthor=item->GetChild("author",1)->value; if(sAuthor==""){ //rdf??? sAuthor=item->GetChild("dc:creator",1)->value; } } //sAuthor=UnescapeString(sAuthor); StripTags(sAuthor); DeEntitize(sAuthor); if(sAuthor!=""){ sTitle+=" ("; sTitle+=sAuthor; sTitle+=")"; } LPXNode pDesk; if(bAtom){ pDesk=item->GetChild("content",1); }else{ pDesk=item->GetChild("description",1); } CString sDesk; if(pDesk->iBeginPos!=-1 && pDesk->iEndPos!=-1){ sDesk=sRSS.Mid(pDesk->iBeginPos,pDesk->iEndPos-pDesk->iBeginPos); } /* if(sDesk.Find("%20")!=-1){ sDesk=UnescapeString(sDesk); } */ CString sDeskL=sDesk; sDeskL.MakeLower(); if(sDeskL.Find(";div")!=-1 || sDeskL.Find(";span")!=-1){ // Для извращенных... DeEntitize(sDesk); StripTags(sDesk); }else{ // Это по правильному StripTags(sDesk); DeEntitize(sDesk); } sDesk.TrimLeft(); sDesk.TrimRight(); CString sLink; if(bAtom){ CXMLNodes feedLinks; item->FindByTagName("link",FALSE,feedLinks); for(int j=0;j<feedLinks.GetSize();j++){ XNode* itemLnk=feedLinks[j]; sLink=itemLnk->GetAttr("href")->value; CString sType=itemLnk->GetAttr("type")->value; sType.MakeLower(); if(sType.Find("text")!=-1){ break;// Наша линка! } } }else{ sLink=item->GetChild("link",1)->value; } sLink=UnescapeString(sLink); StripTags(sLink); DeEntitize(sLink); sLink.TrimLeft(); sLink.TrimRight(); { CSmartLock SL(&csRssFeeds,TRUE); CString sRnewsBuildDate=sLink+"\t"+sPubDate+" "+sTitle+" "+sDesk; if(sLnewsBuildDate==sRnewsBuildDate){ if(iCount==0){ iStatus=1; } break; } if(sLnewsBuildDateToSet==""){// Запомнили самую первую новость sLnewsBuildDateToSet=sRnewsBuildDate; } /* #ifdef _DEBUG else{ sDesk+="\nOld id-text:"+sLnewsBuildDate; sDesk+="\nNew id-text:"+sRnewsBuildDate; } #endif */ } if(sPubDate!=""){ COleDateTime dt; dt.ParseDateTime(sPubDate); if(dt.GetStatus()==COleDateTimeSpan::valid){ sTitle=dt.Format("%x %X. ")+sTitle; } } CString sNews=sTitle; sNews+="\n"; if(sDesk!=""){ sNews+="\n"; sNews+=sDesk; } if(sLink!=""){ sNews+="\n\n"; sNews+=_l("Read more")+": "; sNews+=sLink; } CDataXMLSaver::Xml2Str(sNews); if(objSettings.lRSSSummar){ sSummary+="\n"; sSummary+="\n"; sSummary+=sTitle; sSummary+="\n"; sSummary+=_l("Read more")+": "; sSummary+=sLink; }else{ CString sAttach=""; if(objSettings.dwProtocolRSSOType){ sAttach+=Format("["DEF_OPENTYPE"%i]",objSettings.dwProtocolRSSOType); } OpenMessage(sFrom,"",sNews,"",sAttach,sGlobalTitle); } iCount++; } if(sSummary!=""){ CString sAttach=""; if(objSettings.dwProtocolRSSOType){ sAttach+=Format("["DEF_OPENTYPE"%i]",objSettings.dwProtocolRSSOType); } sSummary.TrimLeft(); OpenMessage(sFrom,"",sSummary,"",sAttach,sGlobalTitle); } if(feedDoc){ delete feedDoc; } if(sLnewsBuildDateToSet!=""){ aLoadedRss.SetAt(szRecipient,sLnewsBuildDateToSet); } } if(iPerson!=-1){ objSettings.AddrBook.aPersons[iPerson]->iOnlineStatus=iStatus; RefreshUserStatusIcon(iPerson); } return 0; }
/***************************************************************************** * ParseText: parse an text subtitle packet and send it to the video output *****************************************************************************/ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block ) { decoder_sys_t *p_sys = p_dec->p_sys; subpicture_t *p_spu = NULL; char *psz_subtitle = NULL; video_format_t fmt; /* We cannot display a subpicture with no date */ if( p_block->i_pts <= VLC_TS_INVALID ) { msg_Warn( p_dec, "subtitle without a date" ); return NULL; } /* Check validity of packet data */ /* An "empty" line containing only \0 can be used to force and ephemer picture from the screen */ if( p_block->i_buffer < 1 ) { msg_Warn( p_dec, "no subtitle data" ); return NULL; } /* Should be resiliant against bad subtitles */ psz_subtitle = malloc( p_block->i_buffer + 1 ); if( psz_subtitle == NULL ) return NULL; memcpy( psz_subtitle, p_block->p_buffer, p_block->i_buffer ); psz_subtitle[p_block->i_buffer] = '\0'; if( p_sys->iconv_handle == (vlc_iconv_t)-1 ) { if (EnsureUTF8( psz_subtitle ) == NULL) { msg_Err( p_dec, "failed to convert subtitle encoding.\n" "Try manually setting a character-encoding " "before you open the file." ); } } else { if( p_sys->b_autodetect_utf8 ) { if( IsUTF8( psz_subtitle ) == NULL ) { msg_Dbg( p_dec, "invalid UTF-8 sequence: " "disabling UTF-8 subtitles autodetection" ); p_sys->b_autodetect_utf8 = false; } } if( !p_sys->b_autodetect_utf8 ) { size_t inbytes_left = strlen( psz_subtitle ); size_t outbytes_left = 6 * inbytes_left; char *psz_new_subtitle = xmalloc( outbytes_left + 1 ); char *psz_convert_buffer_out = psz_new_subtitle; const char *psz_convert_buffer_in = psz_subtitle; size_t ret = vlc_iconv( p_sys->iconv_handle, &psz_convert_buffer_in, &inbytes_left, &psz_convert_buffer_out, &outbytes_left ); *psz_convert_buffer_out++ = '\0'; free( psz_subtitle ); if( ( ret == (size_t)(-1) ) || inbytes_left ) { free( psz_new_subtitle ); msg_Err( p_dec, "failed to convert subtitle encoding.\n" "Try manually setting a character-encoding " "before you open the file." ); return NULL; } psz_subtitle = realloc( psz_new_subtitle, psz_convert_buffer_out - psz_new_subtitle ); if( !psz_subtitle ) psz_subtitle = psz_new_subtitle; } } /* Create the subpicture unit */ p_spu = decoder_NewSubpicture( p_dec, NULL ); if( !p_spu ) { msg_Warn( p_dec, "can't get spu buffer" ); free( psz_subtitle ); return NULL; } /* Create a new subpicture region */ memset( &fmt, 0, sizeof(video_format_t) ); fmt.i_chroma = VLC_CODEC_TEXT; fmt.i_width = fmt.i_height = 0; fmt.i_x_offset = fmt.i_y_offset = 0; p_spu->p_region = subpicture_region_New( &fmt ); if( !p_spu->p_region ) { msg_Err( p_dec, "cannot allocate SPU region" ); free( psz_subtitle ); decoder_DeleteSubpicture( p_dec, p_spu ); return NULL; } /* Decode and format the subpicture unit */ if( p_dec->fmt_in.i_codec != VLC_CODEC_SSA ) { /* Normal text subs, easy markup */ p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; p_spu->p_region->i_x = p_sys->i_align ? 20 : 0; p_spu->p_region->i_y = 10; /* Remove formatting from string */ p_spu->p_region->psz_text = StripTags( psz_subtitle ); if( var_InheritBool( p_dec, "subsdec-formatted" ) ) { p_spu->p_region->psz_html = CreateHtmlSubtitle( &p_spu->p_region->i_align, psz_subtitle ); } p_spu->i_start = p_block->i_pts; p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->b_ephemer = (p_block->i_length == 0); p_spu->b_absolute = false; } else { /* Decode SSA/USF strings */ ParseSSAString( p_dec, psz_subtitle, p_spu ); p_spu->i_start = p_block->i_pts; p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->b_ephemer = (p_block->i_length == 0); p_spu->b_absolute = false; p_spu->i_original_picture_width = p_sys->i_original_width; p_spu->i_original_picture_height = p_sys->i_original_height; } free( psz_subtitle ); return p_spu; }