Click here to Skip to main content
13,089,246 members (66,412 online)
Click here to Skip to main content

Stats

247.8K views
1.1K downloads
32 bookmarked
Posted 25 Jun 2007

RSS Reader Plug-in for Internet Explorer

, 16 Jul 2007
This is a toolbar for the Internet Explorer which shows information from RSS taken from the Internet.
Setup.exe
RssReader_src
RRPRssFetcher
RRPRssFetcher
res
RRPRssFetcher.ico
toolbar.bmp
RRPRssFetcher.vcproj.TEKAWADE.Prafulla V Tekawade.user
RSSReaderplugin
Debug
res
RssReaderPlugin.dll.manifest
RRPComInterfaceImplementor.rgs
RssReaderPlugin.aps
RssReaderPlugin.def
RssReaderPlugin.dsp
RssReaderPlugin.dsw
RssReaderPlugin.opt
RssReaderPlugin.plg
RssReaderPlugin.tlb
RssReaderPlugin.vcproj.TEKAWADE.Prafulla V Tekawade.user
RssReaderPluginps.def
RssReaderPluginps.mk
Setup.iss
/*
	Project		: RSS Reader plugin for Internet Explorer
	File name	: RRPRssFetcher.h
	Date		: 
	Purpose		: It is the class which interacts with the fetcher process
	Note		: Fetcher process and toolbar uses message.txt to exchange messages
	Send comments 
	or Bugs to	: prafulla_t@users.sourceforge.net
*/
#include "stdafx.h"
#include "RRPRssFetcher.h"
#include "RRPConfigurationManager.h"

RRPRssFetcher::RRPRssFetcher(RRPToolbar *toolbar) {
	setToolbar(toolbar);
	rssInfoQueue = std::queue<TRssInfo *>();
	initialize();
}

RRPRssFetcher::~RRPRssFetcher(void) {
	shutDown();
}

void RRPRssFetcher::initialize() {
	RRPConfigurationManager *ptr = toolbar->getConfigManger();
	char *dir = ptr->getInstallationDirectory();
	char *fullRssFetcherName = new char[strlen(dir)+30];
	strcpy(fullRssFetcherName,dir);
	strcat(fullRssFetcherName,"\\RRPRssFetcher.exe");
	fetcherWindowHandle = FindWindow("RRPRssFetcherWindowClass",NULL);
	//Fetcher process not running,starting it.
	if(fetcherWindowHandle == NULL) {
		STARTUPINFO si;
		PROCESS_INFORMATION  pi;
		::ZeroMemory(&si,sizeof(si));
		si.cb = sizeof(si);
		::ZeroMemory(&pi,sizeof(pi));
		BOOL ret = ::CreateProcess(NULL,fullRssFetcherName,NULL,NULL,false,0,NULL,NULL,&si,&pi);
		WaitForInputIdle(pi.hProcess,1000);
	}
	fetcherWindowHandle = FindWindow("RRPRssFetcherWindowClass",NULL);
	if(fetcherWindowHandle == NULL)
		return;
	if(fullRssFetcherName) {
		delete fullRssFetcherName;
		fullRssFetcherName = NULL;
	}
}


void RRPRssFetcher::sendFetchRssRequest(char *localName,char *remoteName) {
	RRPConfigurationManager *ptr = toolbar->getConfigManger();

	TRssInfo* rssInfoT = new TRssInfo();
	strcpy(rssInfoT->localName,localName);
	strcpy(rssInfoT->remoteName,remoteName);
	rssInfoT->message = RRP_RSSFETCH;
	rssInfoT->toolbarHandle = *toolbar;
/*	COPYDATASTRUCT cds;
	cds.cbData=sizeof(TRssInfo);
	cds.dwData=1;
	cds.lpData=(LPVOID)rssInfoT;
	::SendMessage(fetcherWindowHandle,WM_COPYDATA,(WPARAM)0,(LPARAM)&cds);
*/
	rssInfoQueue.push(rssInfoT);
	if(toolbar->isRssFetcherProcessBusy() == false)
		informRSSFetcherProcess(true);
}

//Invoked by the Toolbar only when ACK comes from Fetcher process
void RRPRssFetcher::informRSSFetcherProcess(bool retry) {
	//Queue is empty,No message to send
	if(rssInfoQueue.empty())
		return;
	TRssInfo* rssInfoT = rssInfoQueue.front();
	COPYDATASTRUCT cds;
	cds.cbData=sizeof(TRssInfo);
	cds.dwData=1;
	cds.lpData=(LPVOID)rssInfoT;

	if(!fetcherWindowHandle) 
		fetcherWindowHandle = FindWindow("RRPRssFetcherWindowClass",NULL);
	::SendMessage(fetcherWindowHandle,WM_COPYDATA,(WPARAM)0,(LPARAM)&cds);
	if(retry == false) {
		rssInfoQueue.pop();
		delete rssInfoT;
		rssInfoT = NULL;
	}
}

//If any of the link is modified,we delete all xml files
//In that case it is necessary to tell fetcher process about it
void RRPRssFetcher::sendCleanMessage() {
	if(!fetcherWindowHandle) 
		fetcherWindowHandle = FindWindow("RRPRssFetcherWindowClass",NULL);
	::PostMessage(fetcherWindowHandle,RRP_CLEAN,(WPARAM)0,(LPARAM)0);
}

//Now no need for this message
void RRPRssFetcher::removeRssFromList(char *localName,char *remoteName) {
/*	int n = rssInfoVector.size();
	int i;
	for(i= 0;i<n;i++) {
		if(!strcmp(rssInfoVector[i]->localName,localName))
			rssInfoVector[i] = 0;
	}
	writeFile();*/
	
}

LRESULT RRPRssFetcher::OnFetchComplete(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
	return 0;
}

LRESULT RRPRssFetcher::OnRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
	return 0;
}

void RRPRssFetcher::registerToolbar() {
	if(!fetcherWindowHandle) 
		fetcherWindowHandle = FindWindow("RRPRssFetcherWindowClass",NULL);
	::PostMessage(fetcherWindowHandle,RRP_TOOLBAR_REG,0,0);
}


void RRPRssFetcher::unregisterToolbar() {
	if(!fetcherWindowHandle) 
		fetcherWindowHandle = FindWindow("RRPRssFetcherWindowClass",NULL);
	::PostMessage(fetcherWindowHandle,RRP_TOOLBAR_UNREG,0,0);
	
}

void RRPRssFetcher::shutDown() {
	if(!fetcherWindowHandle) 
		fetcherWindowHandle = FindWindow("RRPRssFetcherWindowClass",NULL);
	::PostMessage(fetcherWindowHandle,WM_CLOSE,0,0);
}

//Old method,now scrapped
void RRPRssFetcher::writeFile() {
/*	int n = rssInfoVector.size();
	RRPConfigurationManager *ptr = new RRPConfigurationManager();
	char *dir = ptr->getInstallationDirectory();
	char *myFile = new char[strlen(dir) + 30];
	HFILE fileHandle;
	strcpy(myFile,dir);
	strcat(myFile,"\\message.txt");
	
	//Creating the file
	OFSTRUCT fileInformation;
	fileHandle = ::OpenFile(myFile,&fileInformation,OF_CREATE);
	::CloseHandle(reinterpret_cast<HANDLE>(fileHandle));
	
	FILE *fp = fopen(myFile,"w");
	int i = 0;
	for(i= 0;i<n-1;i++) {
		if(rssInfoVector[i])
			fprintf(fp,"%s >> %s\n",rssInfoVector[i]->localName,rssInfoVector[i]->remoteName);
	}
	//Short ciruit evaluation
	if(i < n && rssInfoVector[i])
		fprintf(fp,"%s >> %s",rssInfoVector[i]->localName,rssInfoVector[i]->remoteName);
	fclose(fp);

*/
	

/*
	RssInfo FAR* rssInfo = (RssInfo* )::GlobalAlloc(GHND,sizeof(RssInfo));
	rssInfo->localName = (char*)::GlobalAlloc(GHND,10);
	strcpy(rssInfo->localName,"SKKH");
*/	

	//Post is asych..,Cool Na??
//	::SendMessage(fetcherWindowHandle,WM_COPYDATA,(WPARAM)toolbarHandle,(LPARAM)&cds);
//	::SendMessage(fetcherWindowHandle,RRP_RSSFETCH,(WPARAM)0,(LPARAM)0);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

PrafullaT
India India
Quote : "Life is all about solving problems and enjoying their solutions !! "

You may also be interested in...

Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170813.1 | Last Updated 17 Jul 2007
Article Copyright 2007 by PrafullaT
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid