#if 0 WORD NewsReg::queryGroups(Block &subscriberList) { RegKey regKey(RegKey::CurrentUser); String groupString; String newsGroup; DWORD groupNumber(1); subscriberList.remove(); if(!regKey.openKey(mNewsGroupsKeyName))return FALSE; while(TRUE) { ::sprintf(groupString,"%s%ld",(LPSTR)mNewsGroupsKeyValuePrefix,groupNumber++); if(!regKey.queryValue(groupString,newsGroup))break; subscriberList.insert(&newsGroup); } return (subscriberList.size()?TRUE:FALSE); } #endif CallbackData::ReturnType MainWindow::timerHandler(CallbackData &/*someCallbackData*/) { String hostName; killTimer(TimerID); mlpEditWindow->setText(mWSASystem.description()); mlpEditWindow->setText(mWSASystem.systemStatus()); getHostName(hostName); open(hostName); mlpEditWindow->setFocus(); if(!isConnected())return (CallbackData::ReturnType)FALSE; // ListItems listItems("c:\\work\\nntp\\newssrc"); Block articleText; GroupItem groupItem; // group(listItems[285].groupName(),groupItem); group("alt.binaries.pictures.erotica.cheerleaders",groupItem); article(NNTPClient::ByNumber,groupItem.firstArticle(),articleText); message(articleText); // if(isConnected())list(); return (CallbackData::ReturnType)FALSE; } WORD NNTPClient::article(SelectionType selectionType,DWORD selection,Block &articleText) { String controlData; String responseLine; if(!isConnected())return FALSE; articleText.remove(); controlData.reserve(String::MaxString); ::sprintf(controlData,"%s %ld",(LPSTR)mNNTPCmds[Article],selection); if(!putControlData(controlData,FALSE))return FALSE; // if(!mNNTPControl.receive(responseLine))return FALSE; // message(responseLine); receiveStrings(articleText); return TRUE; } // ******************* class MainWindow : public Window, private NNTPThread // private NNTPClient // if(!isConnected())return; // for(int itemIndex=0;itemIndex &articleText,SelectionType selectionType=ByNumber); WORD body(void); WORD head(void); WORD help(void); WORD iHave(void); WORD last(void); WORD newGroups(void); WORD newNews(void); WORD next(void); WORD post(void); WORD stat(void); enum MsgID{MsgOpen,MsgIsConnected,MsgList,MsgQuit,MsgSlave,MsgGroup,MsgArticle,MsgBody, MsgHead,MsgHelp,MsgIHave,MsgLast,MsgNewGroups,MsgNewNews,MsgNext,MsgPost,MsgStat,MsgShutDown}; void handleGroup(GroupItem *pGroupItem); void handleList(void); void handleList(ListItems *pListItems); void handleShutDown(void); void handleQuit(void); void handleSlave(void); void handleArticle(void); void handleBody(void); void handleHead(void); void handleHelp(void); void handleIHave(void); void handleLast(void); void handleNewGroups(void); void handleNext(void); void handlePost(void); void handleStat(void); inline WORD NNTPThread::shutDown(void) { ThreadMessage shutDownMessage(ThreadMessage::TM_USER,MsgShutDown,0L,ThreadMessage::PriorityHigh); return sendMessage(shutDownMessage); } inline WORD NNTPThread::group(const GroupItem &groupItem) { GroupItem *pGroupItem=new GroupItem(groupItem); ThreadMessage groupMessage(ThreadMessage::TM_USER,MsgGroup,(LONG)pGroupItem); return postMessage(groupMessage); } inline WORD NNTPThread::quit(void) { ThreadMessage quitMessage(ThreadMessage::TM_USER,MsgPost,0L); return postMessage(quitMessage); } inline WORD NNTPThread::slave(void) { ThreadMessage slaveMessage(ThreadMessage::TM_USER,MsgSlave,0L); return postMessage(slaveMessage); } inline WORD NNTPThread::article(DWORD selection,Block &articleText,SelectionType selectionType) { ThreadMessage articleMessage(ThreadMessage::TM_USER,MsgArticle,0L); return postMessage(articleMessage); } inline WORD NNTPThread::body(void) { ThreadMessage bodyMessage(ThreadMessage::TM_USER,MsgBody,0L); return postMessage(bodyMessage); } inline WORD NNTPThread::head(void) { ThreadMessage headMessage(ThreadMessage::TM_USER,MsgHead,0L); return postMessage(headMessage); } inline WORD NNTPThread::help(void) { ThreadMessage helpMessage(ThreadMessage::TM_USER,MsgHelp,0L); return postMessage(helpMessage); } inline WORD NNTPThread::iHave(void) { ThreadMessage iHaveMessage(ThreadMessage::TM_USER,MsgIHave,0L); return postMessage(iHaveMessage); } inline WORD NNTPThread::last(void) { ThreadMessage lastMessage(ThreadMessage::TM_USER,MsgLast,0L); return postMessage(lastMessage); } inline WORD NNTPThread::newGroups(void) { ThreadMessage newGroupsMessage(ThreadMessage::TM_USER,MsgNewGroups,0L); return postMessage(newGroupsMessage); } inline WORD NNTPThread::newNews(void) { ThreadMessage newNewsMessage(ThreadMessage::TM_USER,MsgNewNews,0L); return postMessage(newNewsMessage); } inline WORD NNTPThread::next(void) { ThreadMessage nextMessage(ThreadMessage::TM_USER,MsgNext,0L); return postMessage(nextMessage); } inline WORD NNTPThread::post(void) { ThreadMessage postitMessage(ThreadMessage::TM_USER,MsgPost,0L); return postMessage(postitMessage); } inline WORD NNTPThread::stat(void) { ThreadMessage statMessage(ThreadMessage::TM_USER,MsgStat,0L); return postMessage(statMessage); } case MsgGroup : handleGroup((GroupItem*)userData); break; case MsgIsConnected : break; case MsgShutDown : handleShutDown(); break; case MsgList : handleList(); break; case MsgQuit : handleQuit(); break; case MsgSlave : handleSlave(); break; case MsgArticle : handleArticle(); break; case MsgBody : handleBody(); break; case MsgHead : handleHead(); break; case MsgHelp : handleHelp(); break; case MsgIHave : handleIHave(); break; case MsgLast : handleLast(); break; case MsgNewGroups : handleNewGroups(); break; case MsgNext : handleNext(); break; case MsgPost : handlePost(); break; case MsgStat : handleStat(); break; void NNTPThread::handleGroup(GroupItem *pGroupItem) { ThreadMessage groupMessage; ::OutputDebugString("[NNTPThread::handleGroup]\n"); if(isConnected())NNTPClient::group(*pGroupItem); else {delete pGroupItem;pGroupItem=0;} groupMessage.userDataOne((LONG)pGroupItem); callHandler(MsgGroup,groupMessage); if(pGroupItem)delete pGroupItem; } void NNTPThread::handleShutDown(void) { ThreadMessage shutDownMessage; ::OutputDebugString("[NNTPThread::handleShutDown]\n"); if(!NNTPClient::isConnected())return; closeSocket(); callHandler(MsgShutDown,shutDownMessage); } void NNTPThread::handleList(void) { ThreadMessage listMessage; ::OutputDebugString("[NNTPThread::handleList(void)]\n"); callHandler(MsgList,listMessage); } void NNTPThread::handleList(ListItems *pListItems) { ThreadMessage listMessage; ::OutputDebugString("[NNTPThread::handleList(ListItems *pListItems)\n"); callHandler(MsgList,listMessage); } void NNTPThread::handleQuit(void) { ThreadMessage quitMessage; ::OutputDebugString("[NNTPThread::handleQuit\n"); callHandler(MsgQuit,quitMessage); } void NNTPThread::handleSlave(void) { ThreadMessage slaveMessage; ::OutputDebugString("[NNTPThread::handleSlave]\n"); callHandler(MsgSlave,slaveMessage); } void NNTPThread::handleArticle(void) { ThreadMessage articleMessage; ::OutputDebugString("[NNTPThread::handleArticle]\n"); callHandler(MsgArticle,articleMessage); } void NNTPThread::handleBody(void) { ThreadMessage bodyMessage; ::OutputDebugString("[NNTPThread::handleBody]\n"); callHandler(MsgBody,bodyMessage); } void NNTPThread::handleHead(void) { ThreadMessage headMessage; ::OutputDebugString("[NNTPThread::handleHead]\n"); callHandler(MsgHead,headMessage); } void NNTPThread::handleHelp(void) { ThreadMessage helpMessage; ::OutputDebugString("[NNTPThread::handleHelp]\n"); callHandler(MsgHelp,helpMessage); } void NNTPThread::handleIHave(void) { ThreadMessage iHaveMessage; ::OutputDebugString("[NNTPThread::handleIHave]\n"); callHandler(MsgIHave,iHaveMessage); } void NNTPThread::handleLast(void) { ThreadMessage lastMessage; ::OutputDebugString("[NNTPThread::handleLast]\n"); callHandler(MsgLast,lastMessage); } void NNTPThread::handleNewGroups(void) { ThreadMessage newGroupsMessage; ::OutputDebugString("[NNTPThread::handleNewGroups]\n"); callHandler(MsgNewGroups,newGroupsMessage); } void NNTPThread::handleNext(void) { ThreadMessage nextMessage; ::OutputDebugString("[NNTPThread::handleNext]\n"); callHandler(MsgNext,nextMessage); } void NNTPThread::handlePost(void) { ThreadMessage postingMessage; ::OutputDebugString("[NNTPThread::handlePost]\n"); callHandler(MsgPost,postingMessage); } void NNTPThread::handleStat(void) { ThreadMessage statMessage; ::OutputDebugString("[NNTPThread::handleStat]\n"); callHandler(MsgStat,statMessage); } //inline //WORD NNTPThread::isConnected(void) //{ // return NNTPClient::isConnected(); //} #if 0 WORD NNTPClient::article(DWORD selection,Block &articleText,SelectionType selectionType) { String controlData; String responseLine; DWORD responseLines(0); if(!isConnected())return FALSE; articleText.remove(); controlData.reserve(String::MaxString); if(ByNumber==selectionType)::sprintf(controlData,"%s %ld",(LPSTR)mNNTPCmds[Article],selection); else ::sprintf(controlData,"<%s> %ld",(LPSTR)mNNTPCmds[Article],selection); if(!putControlData(controlData,FALSE))return FALSE; while(mNNTPControl.receive(responseLine)) { if(mPeriod==responseLine&&1==responseLine.length())break; if(!responseLines++) { String responseString(responseLine.betweenString(0,' ')); if(isInResponse(responseString,mNackArticleResponseStrings))break; if(isInResponse(responseString,mAckArticleResponseStrings))continue; } articleText.insert(&responseLine); } return (articleText.size()?TRUE:FALSE); } #endif // WORD article(DWORD selection,Block &articleText,SelectionType selectionType=ByNumber); // WORD article(DWORD msgNumber,Block &articleText); // WORD article(const MsgID &msgID,Block &articleText); // WORD body(DWORD selection,Block &bodyText,SelectionType selectionType); // WORD head(DWORD selection,Block &headText,SelectionType selectionType); #if 0 WORD NNTPClient::head(DWORD selection,Block &headText,SelectionType selectionType) { String controlData; String responseLine; DWORD responseLines(0); if(!isConnected())return FALSE; headText.remove(); controlData.reserve(String::MaxString); if(ByNumber==selectionType)::sprintf(controlData,"%s %ld",(LPSTR)mNNTPCmds[Head],selection); else ::sprintf(controlData,"<%s> %ld",(LPSTR)mNNTPCmds[Head],selection); if(!putControlData(controlData,FALSE))return FALSE; while(mNNTPControl.receive(responseLine)) { if(mPeriod==responseLine&&1==responseLine.length())break; if(!responseLines++) { String responseString(responseLine.betweenString(0,' ')); if(isInResponse(responseString,mNackArticleResponseStrings))break; if(isInResponse(responseString,mAckArticleResponseStrings))continue; } headText.insert(&responseLine); } return (headText.size()?TRUE:FALSE); } #endif #if 0 WORD MainWindow::getNewNews(void) { Block messageIDStrings; Block newsGroups; Block distributionGroups; SystemTime systemTime; WORD isGMT(FALSE); systemTime.hour(0); systemTime.minute(0); systemTime.second(0); newsGroups.insert(&String("alt.sounds")); newsGroups.insert(&String("alt.sounds.samples")); distributionGroups.insert(&String("rec.music")); distributionGroups.insert(&String("rec.wav")); isGMT=TRUE; newNews(newsGroups,distributionGroups,messageIDStrings,systemTime,isGMT); return FALSE; } #endif WORD MainWindow::saveNews(const String &newsGroup) { Block articleText; GroupItem groupItem; DiskInfo diskInfo; WORD okResult; diskInfo.createDirectory(newsGroup); diskInfo.setCurrentDirectory(newsGroup); groupItem.groupName(newsGroup); group(groupItem); for(int articleNumber=groupItem.firstArticle();articleNumber<=groupItem.lastArticle();articleNumber++) { if(!isConnected())return FALSE; String articleName; ::sprintf(articleName,"n%ld.new",articleNumber++); message(articleName); okResult=article(articleNumber,articleText); if(okResult) { FileHandle saveFile(articleName,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite); for(int itemIndex=0;itemIndexisOkay()){delete mlpRasInterface;mlpRasInterface=0;return FALSE;} if(!mlpRasInterface->login(rasUserName,rasPassword,rasEntryName)){delete mlpRasInterface;mlpRasInterface=0;return FALSE;} return TRUE; #endif sendMessage(NewsGroupList,WM_SETREDRAW,FALSE,0L); sendMessage(NewsGroupList,LB_RESETCONTENT,0,0L); for(int itemIndex=0;itemIndex &subscriberList) { RegKey regKey(RegKey::CurrentUser); String groupString; String newsGroup; String nameValue; DWORD groupIndex(0); subscriberList.remove(); if(!regKey.openKey(mNewsGroupsKeyName))return FALSE; while(regKey.enumValue(groupIndex++,nameValue,newsGroup)) subscriberList.insert(&newsGroup); return (subscriberList.size()?TRUE:FALSE); } #endif //inline //void NNTPThread::insertOpenHandler(ThreadCallbackPointer pThreadCallback) //{ // mEventHandler=ThreadCallbackPointer(pThreadCallback); //} //inline //void NNTPThread::removeOpenHandler(void) //{ // mEventHandler=ThreadCallbackPointer(); //} // void insertOpenHandler(ThreadCallbackPointer pThreadCallback); // void removeOpenHandler(void); // ThreadCallbackPointer mEventHandler; if(systemTime.month()>=optionsReg.month()&& systemTime.day()>=optionsReg.day()&& systemTime.year()>=optionsReg.year()&& systemTime.hour()>=optionsReg.hour()&& systemTime.minute()>=optionsReg.minute())break; #if 0 // makeTimeDateString(postDate,systemTime); // setText(PostDate,postDate); SystemTime systemTime; SystemTime someTime(1997,12,1,5,0,0); String timeDateString((String)someTime); timeDateString+="\n"; ::OutputDebugString(timeDateString); // message((String)someTime); #endif void OptionsDialog::makeTimeDateString(String &timeDateString,const SystemTime &systemTime)const { timeDateString.reserve(String::MaxString); ::sprintf(timeDateString,"%02d%02d%02d %02d%02d%02d", systemTime.year()>2000?2000-systemTime.year():systemTime.year()-1900, systemTime.month(), systemTime.day(), systemTime.hour(), systemTime.minute(), systemTime.second()); } void makeTimeDateString(String &timeDateString,const SystemTime &systemTime)const; // SystemTime postDateTime(systemTime.year(),systemTime.month(),systemTime.day(), // systemTime.hour(),systemTime.minute(),systemTime.second()); #if 0 void MainWindow::handleRetrieveNews(void) { String hostName; if(!getSubscriberList(mSubscriberList)){message("No newsgroups in subscriber list, nothing to do!");return;} mlpEditWindow->setFocus(); getHostName(hostName); mCancelWait=FALSE; open(hostName); } #endif addRootNode(FolderTree::FolderClosed,pathDir,makeItemID(RootNode,1)); pathFind.dirList(pathDir,dirList); if(dirList.size()<=2)return FALSE; if(!makeFileName(dirList[0],entryName))return FALSE; if(entryName!=String("."))return FALSE; if(!makeFileName(dirList[1],entryName))return FALSE; if(entryName!=String(".."))return FALSE; for(int itemIndex=2;itemIndex dirEntries; getList(pathEntryName,dirEntries,FileList); { for(int itemIndex=0;itemIndex::Delete); controlRect.top(controlRect.bottom()+1); controlRect.bottom(height()/2); mEditWindow=new EditWindow(&((Window&)*this),controlRect); mEditWindow->disposition(SmartPointer::Delete); KeyControl keyControl; keyControl.canScroll(TRUE); mEditWindow->setKeyControl(keyControl); mEditWindow->setLineHandler(&mLineHandler); mDirTree->showDirList("e:\\download"); #endif WORD DirTree::showDirList(const String &pathDir,Block &dirEntries,NodeType nodeType) { String entryName; // remove(); if(!dirEntries.size())return FALSE; if(DirNode==nodeType)addRootNode(FolderTree::FolderClosed,pathDir,makeItemID(RootNode,1)); for(int itemIndex=0;itemIndex*)mEditMonitor))->setFocus(); getHostName(hostName); mCancelWait=FALSE; open(hostName); } #if 0 DWORD MainWindow::preOpenHandler(ThreadMessage &/*someThreadMessage*/) { if(!waitForScheduledEvent())return TRUE; if(!dialHost()) { message("Could not contact host."); return TRUE; } return FALSE; } #endif WORD MainWindow::retrieveNews(const String &newsGroup,Block &filterList,FilterReg::FilterMode mode) { Block messageIDStrings; DiskInfo diskInfo; DWORD pastDays; String msgString; WORD okResult; diskInfo.createDirectory(newsGroup); diskInfo.setCurrentDirectory(newsGroup); message(String("Retrieving message headers for ")+newsGroup); newNews(newsGroup,messageIDStrings,priorDays()); ::sprintf(msgString,"%s has %ld articles.",(LPSTR)newsGroup,messageIDStrings.size()); message(msgString); for(int itemIndex=0;itemIndex articleText; Block headerLines; String pathFileName; MsgID msgID; if(!isConnected())return FALSE; msgID=messageIDStrings[itemIndex]; ::sprintf(pathFileName,"n%ld.new",itemIndex); message(newsGroup+String("(")+msgID+String(")")); if(mMasterList.searchItem(msgID)) { message(String("Already have ")+msgID); continue; } mMasterList.insert(msgID); okResult=head(msgID,headerLines); Header articleHeader(headerLines); if(isInFilter(articleHeader,filterList,mode)) { message(String("Skipping ")+msgID+String(" because article source is being filtered.")); continue; } okResult=article(msgID,articleText); if(okResult)saveBlock(pathFileName,articleText); } diskInfo.setCurrentDirectory(".."); return TRUE; } WORD MainWindow::isInFilter(Header &articleHeader,Block &filterList,FilterReg::FilterMode mode) { for(int itemIndex=0;itemIndex messageIDStrings; DiskInfo diskInfo; DWORD pastDays; String msgString; WORD okResult; diskInfo.createDirectory(newsGroup); diskInfo.setCurrentDirectory(newsGroup); message(String("Retrieving message headers for ")+newsGroup); simulateNewNews(newsGroup,messageIDStrings,priorDays()); ::sprintf(msgString,"%s has %ld articles.",(LPSTR)newsGroup,messageIDStrings.size()); message(msgString); messageLog.setLog("MSGLOG.001"); for(int itemIndex=0;itemIndex articleText; String pathFileName; MsgID msgID; if(!isConnected())return FALSE; msgID=messageIDStrings[itemIndex]; ::sprintf(pathFileName,"n%ld.new",itemIndex); message(newsGroup+String("(")+msgID+String(")")); if(mMasterList.searchItem(msgID)) { message(String("Already have ")+msgID); continue; } mMasterList.insert(msgID); okResult=article(msgID,articleText); if(okResult)saveBlock(pathFileName,articleText); } diskInfo.setCurrentDirectory(".."); return TRUE; } #endif WORD MainWindow::retrieveNews(const String &newsGroup) { Block messageIDStrings; DiskInfo diskInfo; GenDecode genericDecoder; DWORD pastDays; String msgString; WORD okResult; diskInfo.createDirectory(newsGroup); diskInfo.setCurrentDirectory(newsGroup); message(String("Retrieving message headers for ")+newsGroup); newNews(newsGroup,messageIDStrings,priorDays()); ::sprintf(msgString,"%s has %ld articles.",(LPSTR)newsGroup,messageIDStrings.size()); message(msgString); for(int itemIndex=0;itemIndex articleText; String pathFileName; MsgID msgID; if(!isConnected())return FALSE; msgID=messageIDStrings[itemIndex]; ::sprintf(pathFileName,"n%ld.new",itemIndex); message(newsGroup+String("(")+msgID+String(")")); if(mMasterList.searchItem(msgID)) { message(String("Already have ")+msgID); continue; } mMasterList.insert(msgID); okResult=article(msgID,articleText); if(okResult) { saveBlock(pathFileName,articleText); if(genericDecoder.decode(pathFileName))::unlink(pathFileName); } } diskInfo.setCurrentDirectory(".."); return TRUE; } WORD MainWindow::retrieveNewsSim(const String &newsGroup) { MessageLog messageLog; Block messageIDStrings; GenDecode genericDecoder; DiskInfo diskInfo; DWORD pastDays; String msgString; WORD okResult; diskInfo.createDirectory(newsGroup); diskInfo.setCurrentDirectory(newsGroup); message(String("Retrieving message headers for ")+newsGroup); String strRecover(newsGroup); String strMsgLog(newsGroup); strRecover+=".001"; strMsgLog+=".002"; FileIO msgIDFile; msgIDFile.open(strRecover,FileIO::GenericRead,FileIO::FileShareRead,FileIO::OpenExisting,FileIO::Archive); if(msgIDFile.isOkay()) { MsgID msgID; message(String("using recovery file.")); while(msgIDFile.readLine(msgID))messageIDStrings.insert(&msgID); msgIDFile.close(); } else { simulateNewNews(newsGroup,messageIDStrings,priorDays()); FileIO msgIDFile; msgIDFile.open(strRecover,FileIO::GenericWrite,FileIO::FileShareRead,FileIO::OpenAlways,FileIO::Archive); for(int itemIndex=0;itemIndex articleText; String pathFileName; MsgID msgID; if(!isConnected())return FALSE; msgID=messageIDStrings[itemIndex]; ::sprintf(pathFileName,"n%ld.new",itemIndex); message(newsGroup+String("(")+msgID+String(")")); if(messageLog.searchItem(msgID)){message(String("Already have ")+msgID);continue;} messageLog.insert(msgID); okResult=article(msgID,articleText); if(okResult) { saveBlock(pathFileName,articleText); if(genericDecoder.decode(pathFileName))::unlink(pathFileName); } okResult=FALSE; messageLog.flush(); } messageLog.close(); diskInfo.setCurrentDirectory(".."); return TRUE; } //#include //#include //#include // //HINSTANCE Main::smhInstance=0; //HINSTANCE Main::smhPrevInstance=0; //int Main::smnCmdShow=0; // //int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR /*lpszCmdLine*/,int nCmdShow) //{ // Main::processInstance(hInstance); // Main::previousProcessInstance(hPrevInstance); // Main::cmdShow(nCmdShow); // if(Main::previousProcessInstance()) // { // HWND hWnd=::FindWindow(MainWindow::className(),MainWindow::className()); // if(!hWnd) // { // ::MessageBox(::GetFocus(),(LPSTR)"Failed to maximize previous instance",(LPSTR)"Error",MB_ICONSTOP|MB_SYSTEMMODAL); // return FALSE; // } // ::PostMessage(hWnd,WM_REACTIVATE,0,0L); // return FALSE; // } // MainWindow applicationWindow; // return ((GUIWindow&)applicationWindow).messageLoop(); } void MainFrame::registerClass(void)const { HINSTANCE hInstance(processInstance()); WNDCLASS wndClass; if(::GetClassInfo(hInstance,className(),(WNDCLASS FAR*)&wndClass))return; wndClass.style =CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS; wndClass.lpfnWndProc =(WNDPROC)Window::WndProc; wndClass.cbClsExtra =0; wndClass.cbWndExtra =sizeof(MainWindow*); wndClass.hInstance =hInstance; wndClass.hIcon =::LoadIcon(NULL,IDI_APPLICATION); wndClass.hCursor =::LoadCursor(NULL,IDC_ARROW); wndClass.hbrBackground =(HBRUSH)::GetStockObject(LTGRAY_BRUSH); wndClass.lpszMenuName =szMenuName; wndClass.lpszClassName =szClassName; ::RegisterClass(&wndClass); assert(0!=::GetClassInfo(hInstance,className(),(WNDCLASS FAR*)&wndClass)); } messageLog.setLog(newsGroup); for(int itemIndex=0;itemIndex articleText; String pathFileName; MsgID msgID; if(!isConnected())return FALSE; msgID=messageIDStrings[itemIndex]; ::sprintf(pathFileName,"n%ld.new",itemIndex); message(newsGroup+String("(")+msgID+String(")")); if(messageLog.searchItem(msgID)){message(String("Already have ")+msgID);continue;} messageLog.insert(msgID); okResult=article(msgID,articleText); if(okResult) { saveBlock(pathFileName,articleText); if(genericDecoder.decode(pathFileName))::unlink(pathFileName); } okResult=FALSE; messageLog.flush(); } messageLog.close(); // messageLog.setLog(newsGroup); // for(int itemIndex=0;itemIndex articleText; // String pathFileName; // MsgID msgID; // // if(!isConnected())return FALSE; // msgID=messageIDStrings[itemIndex]; // ::sprintf(pathFileName,"n%ld.new",itemIndex); // message(newsGroup+String("(")+msgID+String(")")); // if(messageLog.searchItem(msgID)){message(String("Already have ")+msgID);continue;} // messageLog.insert(msgID); // okResult=article(msgID,articleText); // if(okResult) // { // saveBlock(pathFileName,articleText); // if(genericDecoder.decode(pathFileName))::unlink(pathFileName); // } // okResult=FALSE; // messageLog.flush(); // } // messageLog.close(); WORD MainFrame::retrieveNews(const String &newsGroup) { RecoverLog recoverLog; Block messageIDStrings; DiskInfo diskInfo; String msgString; diskInfo.createDirectory(newsGroup); diskInfo.setCurrentDirectory(newsGroup); message(String("Retrieving message headers for ")+newsGroup); if(recoverLog.haveLog(newsGroup)) { message(String("using recovery file.")); recoverLog.getEntries(newsGroup,messageIDStrings); } else { simulateNewNews(newsGroup,messageIDStrings,priorDays()); recoverLog.setEntries(newsGroup,messageIDStrings); } // simulateNewNews(newsGroup,messageIDStrings,priorDays()); ::sprintf(msgString,"%s has %ld articles.",(LPSTR)newsGroup,messageIDStrings.size()); message(msgString); getArticles(newsGroup,messageIDStrings); diskInfo.setCurrentDirectory(".."); return TRUE; } CallbackData::ReturnType ImageView::paintHandler(CallbackData &someCallbackData) { CursorControl cursorControl; cursorControl.waitCursor(TRUE); mMutex.requestMutex(); if(!mJPGImage.isOkay()) { mMutex.releaseMutex(); cursorControl.waitCursor(FALSE); return (CallbackData::ReturnType)FALSE; } PaintInformation &paintInfo=*((PaintInformation*)someCallbackData.lParam()); PureDevice &paintDevice=(PureDevice&)paintInfo; if(mScrollInfo.sizeEvent()) { mScrollInfo.sizeEvent(FALSE); mJPGImage.draw(paintDevice,mScrollInfo.currScrollx(),mScrollInfo.currScrolly()); } if(mScrollInfo.scrollEvent()) { Rect paintRect(paintInfo.paintRect()); mScrollInfo.scrollEvent(FALSE); paintRect.right(paintRect.right()-paintRect.left()); paintRect.bottom(paintRect.bottom()-paintRect.top()); mJPGImage.draw(paintDevice,,Point(paintRect.left()+mScrollInfo.currScrollx(),paintRect.top()+mScrollInfo.currScrolly())); } // if(mJPGImage.width() &msgIDs) { MessageLog messageLog; GenDecode genericDecoder; DWORD alreadyHavesInARow(0); BOOL okResult; messageLog.setLog(newsGroup); alreadyHavesInARow=0; group(GroupItem(newsGroup)); for(int itemIndex=0;itemIndex articleText; String pathFileName; MsgID msgID; if(!isConnected())return FALSE; msgID=msgIDs[itemIndex]; ::sprintf(pathFileName,"n%ld.new",itemIndex); message(newsGroup+String("(")+msgID+String(")")); if(messageLog.searchItem(msgID)) { message(String("Already have ")+msgID); alreadyHavesInARow++; if(alreadyHavesInARow>250) { Block headText; message("...1 second, I need to ping the News Server..."); head(msgID,headText); alreadyHavesInARow=0; } continue; } else alreadyHavesInARow=0; messageLog.insert(msgID); okResult=article(msgID,articleText); if(okResult) { String strPathImageFile; saveBlock(pathFileName,articleText); genericDecoder.decode(pathFileName,strPathImageFile); if(!strPathImageFile.isNull()&&openImage(strPathImageFile))::unlink(pathFileName); // if(genericDecoder.decode(pathFileName,strPathImageFile)) // { // ::unlink(pathFileName); // openImage(strPathImageFile); // } } okResult=FALSE; messageLog.flush(); } messageLog.close(); return TRUE; } WORD MainFrame::retrieveNews(const String &newsGroup) { DiskInfo diskInfo; RecoverLog recoverLog; Block messageIDStrings; String msgString; String strNewsDir; String strPathNewsGroupDirectory; String strPreviousDirectory; OptionsReg optionsReg; strNewsDir=optionsReg.newsDir(); strPathNewsGroupDirectory=strNewsDir+String("\\")+newsGroup; if(!diskInfo.setCurrentDirectory(strPathNewsGroupDirectory)) { diskInfo.createDirectory(strPathNewsGroupDirectory); diskInfo.setCurrentDirectory(strPathNewsGroupDirectory); } message(String("Retrieving message headers for ")+newsGroup); if(recoverLog.haveLog(newsGroup)) { message(String("using recovery file.")); recoverLog.getEntries(newsGroup,messageIDStrings); } else { // simulateNewNews(newsGroup,messageIDStrings,priorDays()); // newNews(newsGroup,messageIDStrings,priorDays()); listGroup(newsGroup,messageIDStrings); recoverLog.setEntries(newsGroup,messageIDStrings); } // simulateNewNews(newsGroup,messageIDStrings,priorDays()); // newNews(newsGroup,messageIDStrings,priorDays()); // listGroup(newsGroup,messageIDStrings); ::sprintf(msgString,"%s has %ld articles.",(LPSTR)newsGroup,messageIDStrings.size()); message(msgString); getArticles(newsGroup,messageIDStrings); diskInfo.setCurrentDirectory(strNewsDir); return TRUE; } void ImageView::preRegister(WNDCLASS &wndClass) { wndClass.style|=CS_SAVEBITS|CS_OWNDC; wndClass.hbrBackground=(HBRUSH)::GetStockObject(WHITE_BRUSH); // wndClass.hbrBackground=(HBRUSH)COLOR_APPWORKSPACE; } void JPGImage::verifyDimensions(BitmapInfo &someBitmapInfo) { DWORD desiredHeight(mBitmapInfo.height()<0?-mBitmapInfo.height():mBitmapInfo.height()); DWORD desiredWidth(mBitmapInfo.width()); DWORD imageExtent; imageExtent=(((((LONG)desiredWidth*8)+31)&~31)>>3)*(LONG)desiredHeight; if(imageExtent==(LONG)desiredWidth*(LONG)desiredHeight)return; else desiredWidth=(WORD)(imageExtent/(LONG)desiredHeight); mBitmapInfo.width(desiredWidth); } for(int index=0;index rawData; PakEntry pakEntry; // String strPathFileName(strPathDirectory+String("\\")+strPathFileNames[index]); // mThumbPage.insert(strPathFileName,pureDevice); String &strPathFileName=strPathFileNames[index]; mThumbPage.insert(strPathFileName,pureDevice); mThumbPage[mThumbPage.entries()-1].getRawData(rawData); pakEntry.type(PakEntry::Blob); pakEntry.name(strPathFileName); pakEntry.id(mMediaPak.entries()); pakEntry.rawData(rawData); mMediaPak.add(pakEntry); } } // enum {DefaultWidth=96,DefaultHeight=96,DefaultResampleWidth=96,OffsetImage=(DefaultWidth-DefaultResampleWidth)/2,BottomBorderHeight=0}; enum {DefaultWidth=72,DefaultHeight=72,DefaultResampleWidth=72,OffsetImage=(DefaultWidth-DefaultResampleWidth)/2,BottomBorderHeight=0}; ThumbNail(const ThumbNail &someThumbNail); ThumbNail &operator=(const ThumbNail &someThumbNail); const RGBColor &light(void)const; const RGBColor &dark(void)const; for(index=0;index rawData; PakEntry pakEntry; ::OutputDebugString(String("Adding ")+strPathDirFileNames[index]+String("\n")); strPathFileNames.insert(strPathDirFileNames[index]); String strPathFileName(strPathDirectory+String("\\")+strPathDirFileNames[index]); // mThumbPage.insert(strPathFileName,pureDevice); mThumbPage.insert(strPathFileName); mThumbPage[mThumbPage.entries()-1].getRawData(rawData); pakEntry.type(PakEntry::Blob); pakEntry.name(strPathDirFileNames[index]); pakEntry.id(mMediaPak.entries()); pakEntry.rawData(rawData); mMediaPak.add(pakEntry); } } void JPGImage::verifyDimensions(BitmapInfo &someBitmapInfo) { DWORD desiredHeight(someBitmapInfo.height()<0?-someBitmapInfo.height():someBitmapInfo.height()); DWORD desiredWidth(someBitmapInfo.width()); DWORD imageExtent; // imageExtent=(((((LONG)desiredWidth*8)+31)&~31)>>3)*(LONG)desiredHeight; imageExtent=(((((LONG)desiredWidth*24)+31)&~31)>>3)*(LONG)desiredHeight; if(imageExtent==(LONG)desiredWidth*(LONG)desiredHeight)return; else desiredWidth=(WORD)(imageExtent/(LONG)desiredHeight); someBitmapInfo.width(desiredWidth); } /* CallbackData::ReturnType MainFrame::browseSelectHandler(CallbackData &someCallbackData) { SmartPointer mdiWindow; String strPathFileName; String strCaption; bool haveImage(false); strPathFileName=(char*)someCallbackData.lParam(); if(getFirstDocument(mdiWindow)) { mdiWindow->windowText(strCaption); strCaption=strCaption.betweenString('[',']'); if(!strCaption.isNull()&&strCaption==strPathFileName) { mdiWindow->bringWindowToTop(); haveImage=true; } while(!haveImage&&getNextDocument(mdiWindow)) { mdiWindow->windowText(strCaption); strCaption=strCaption.betweenString('[',']'); if(!strCaption.isNull()&&strCaption==strPathFileName) { mdiWindow->bringWindowToTop(); haveImage=true; } } } if(haveImage)return (CallbackData::ReturnType)FALSE; if(!openDocument(strPathFileName))::MessageBox(::GetFocus(),"NNTP:Error opening document",(LPSTR)strPathFileName,MB_OK); return (CallbackData::ReturnType)FALSE; } */ String pathFileName; for(int index=0;index<50;index++) { ::sprintf(pathFileName,"d:\\file_%02d.dat",index); FileHandle saveFile(pathFileName,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite); saveFile.writeLine(pathFileName); } ::Sleep(60000); BOOL MainFrame::getArticles(const String &newsGroup,Block &msgIDs) { MessageLog messageLog; GenDecode genericDecoder; DWORD alreadyHavesInARow(0); BOOL okResult; messageLog.setLog(newsGroup); alreadyHavesInARow=0; group(GroupItem(newsGroup)); for(int itemIndex=0;itemIndex articleText; String pathFileName; MsgID msgID; if(!isConnected())return FALSE; msgID=msgIDs[itemIndex]; // ::sprintf(pathFileName,"n%ld.new",itemIndex); // message(newsGroup+String("(")+msgID+String(")")); if(messageLog.searchItem(msgID)) { // message(String("Already have ")+msgID); alreadyHavesInARow++; if(alreadyHavesInARow>250) { Block headText; // message("...1 second, I need to ping the News Server..."); head(msgID,headText); alreadyHavesInARow=0; } continue; } else { ::sprintf(pathFileName,"n%ld.new",itemIndex); message(newsGroup+String("(")+msgID+String(")")); alreadyHavesInARow=0; } messageLog.insert(msgID); /* okResult=head(msgID,articleText); Header header(articleText); message(header.subject()); String subject=header.subject(); subject.upper(); if(!subject.strstr("YENC")) { message(String("Skipping ")+header.subject()); continue; }*/ okResult=article(msgID,articleText); if(okResult) { String strPathImageFile; saveBlock(pathFileName,articleText); try { if(!YDecoder::decode(pathFileName,strPathImageFile)) { genericDecoder.decode(pathFileName,strPathImageFile); } // if(!genericDecoder.decode(pathFileName,strPathImageFile)) // { // YDecoder::decode(pathFileName,strPathImageFile); // } } catch(...) { continue; } if(!strPathImageFile.isNull()&&openImage(strPathImageFile))::unlink(pathFileName); } okResult=FALSE; messageLog.flush(); } messageLog.close(); return TRUE; } // if(!YDecoder::decode(pathFileName,strPathImageFile)) // { // if(!genericDecoder.decode(pathFileName,strPathImageFile)) // } /* try { if(!YDecoder::decode(pathFileName,strPathImageFile)) { genericDecoder.decode(pathFileName,strPathImageFile); } } catch(...) { continue; } */ //#if defined(_MSC_VER) //#pragma warning(disable:4355) //#endif class NNTPThread : private MessageThread, public NNTPClient WORD NNTPClient::article(DWORD articleNumber,Block &articleText,String &messageID) { String controlData; String responseLine; DWORD responseLines(0); ::sprintf(controlData,"%s %ld",(LPSTR)mNNTPCmds[Article],articleNumber); articleText.remove(); if(!isConnected())return FALSE; if(!putControlData(controlData,FALSE))return FALSE; while(mNNTPControl.receive(responseLine)) { if(mPeriod==responseLine && 1==responseLine.length())break; if(!responseLines++) { String responseString(responseLine.betweenString(0,' ')); messageID=responseLine.betweenString('<','>'); if(mNackArticleResponseStrings.size() && isInResponse(responseString,mNackArticleResponseStrings))break; if(mAckArticleResponseStrings.size() && isInResponse(responseString,mAckArticleResponseStrings))continue; } articleText.insert(&responseLine); } return (articleText.size()?TRUE:FALSE); // return retrieveBlock(controlData,articleText,mAckArticleResponseStrings,mNackArticleResponseStrings); }