Skip to main content

Articles

Featured Products

Windows Mobile Developer Controls
Windows Mobile Developer Controls
Stay in touch using the DEVBUSS RSS feeds.
 

News

Windows Mobile Developer Controls
Windows Mobile Developer Controls

.NET CF Newsreader using IP*Works!

Written by Lance Robinson  [author's bio]  [read 30697 times]
Edited by Derek

Download the code

Page 1  Page 2 

The world of today demands mobility. Consumers want to be online everywhere they go - whether it be in the home or office, in the car on a road trip, or even at the beach.

Using IP*Works!, developers can easily give their embedded applications the power of connectivity. Your embedded applications can manage files remotely with the FTP, HTTP, or RCP components. With IP*Works! its easy to read email or news online with the IMAP, POP, or NNTP components. Writing proprietary client applications becomes a very simple task when using the IPPort TCP/IP client component. Extremely fast Zip, Gzip, Tar, and Jar compression/decompression and archiving capabilities are made possible with the IP*Works! Zip toolkit. Secure credit card processing can be performed with just a few lines of code using IP*Works! CC. All of this power can make your embedded applications true mobile connected applications.

Today's embedded developers have the choices of what development environment to use, what language to use, and what components to use. VS.Net device applications take advantage of the .Net Compact Framework to create applications that will run on any Windows CE or Pocket PC device, regardless of what processor its using. The device just has to have the Compact Framework installed. Some developers prefer to work with the Embedded Visual Tools products, the most popular of which being version 3. EVT V3 included eVB and eVC++. eVC++ V4 is also available.

IP*Works! provides product suites for all of these environments. Even better, a secure IP*Works! SSL edition is also available for Pocket PC 2002 developers.

.NET Compact Framework Edition Fully-managed .NET Components
ActiveX Edition for Pocket PC 2002 32 bit ActiveX Controls
ActiveX Edition for Pocket PC 2000 32 bit ActiveX Controls
ActiveX Edition for HPC 2000 32 bit ActiveX Controls
SSL ActiveX Edition for Pocket PC 2002 32 bit ActiveX Controls
C++ Edition for Pocket PC 2002 32 bit C++ Classes
C++ Edition for Pocket PC 2000 32 bit C++ Classes
C++ Edition for HPC 2000 32 bit C++ Classes
C++ Edition for Smart Phone 32 bit C++ Classes
.NET Compact Framework Edition Fully-managed .NET Components
SSL .NET Compact Framework Edition Fully-managed .NET Components
Zip .NET Compact Framework Edition Fully-managed .NET Components
IM .NET Compact Framework Edition Fully-managed .NET Components
CC .NET Compact Framework Edition Fully-managed .NET Components

 

One important goal of embedded development is to give devices the power to do anything that can be done on a desktop. Leveraging IP*Works! enables developers to do this.

Take the case of news browsing: On the desktop, this is an easy thing to do. There are many powerful news browsers available - but that is not the case for devices. The fact is that with IP*Works!, creating a news reader for embedded devices is relatively trivial. The most difficult part is not the internet communication, but arranging the articles by thread. One way to handle that threading is to use the treeview control.

Download Articles From News Server

Newsgroup articles are kept on the news server in order of arrival, not in order of message thread or subject. Rather than display articles this way, I'll of course want to "thread" these messages so that replies will fall under their parent message in that nice threaded tree view that we're all accustomed to.

I don't want to download all of the articles at once - or even one article. Instead, I am just going to download a list of article headers. In order to download these article headers, as well as other information about a range of articles, use the NNTP object's GroupOverview method. This method will ask the news server for information about all of the articles specified in the OverviewRange. For this example, I'll just download the 100 most recent messages.

Nntp1.NewsServer = "msnews.microsoft.com"
Nntp1.CurrentGroup = "microsoft.public.dotnet.framework.compactframework"
Nntp1.OverviewRange = CStr(Nntp1.LastArticle - 100) & "-" & Nntp1.LastArticle
Nntp1.GroupOverview() Nntp1.Disconnect()

The GroupOverview method will begin downloading article information from the news server. For each message, a GroupOverview event will fire. This event returns with the following parameters:

ArticleNumber number of the article within the group
Subject the subject of the article
From email address of the article author
ArticleDate date the article was posted
MessageId unique message id for the article
References message ids for the articles this article refers to (separated by spaces)
ArticleSize size of the article in bytes
ArticleLines the number of lines in the article
OtherHeaders other article headers that NewsServer provides for the article

It is within this event that we will begin to build a tree of articles, each branch representing a different thread. We will do this by using the MessageId and References headers provided here.

The Message-ID header uniquely identifies each nntp article. Here are 5 message-ID sample values:

<e8ZlPf8rCHA.1132@TK2MSFTNGP12>
<vARP9.2130$L61.370841@news1.west.cox.net>
<OKG$Dr8rCHA.2484@TK2MSFTNGP10>
<KV_P9.4450$9N5.440007@newsread2.prod.itd.earthlink.net>
<3E1086F3.2050805@.com>

The References header contains the message-ID's of all of the preceeding messages in the thread. This means that the first message in a thread does not have a References header, since there were no messages before it in the thread. Only replies will have a References header. In this way, a "chain" is created, linking each message to its "parent".

For example, consider a new message, the first in its thread, posted by Tom B. Since this is the first message in the thread, it will not contain a references header.

Next, Sally C replies to Tom's message. Her article will contain a references header containing the message-ID from Tom's message.

Next, John D replied to Sally. His references header has the value of Sally's reference header, plus Sally's message-ID.

Finally, Mike E posts a second reply to Tom's original message. Just like Sally's message, his reference header contains only a reference to Tom's message.

[original message from Tom B.] From: Tom B. Subject: This is a new thread about smurfs Message-ID: <abc123@mynetwork.com> [Sally C replies to Tom B., includes a ref to his message] From: Sally C. Subject: Re[1]: This is a new thread about smurfs Message-ID: <abc456@othernetwork.com> References: <abc123@mynetwork.com> [John D. replies to Sally C., inc Sally's ref and msgid] From: John D. Subject: Re[2]: This is a new thread about smurfs Message-ID: <abc789@thatnetwork.com> References: <abc123@mynetwork.com>, <abc456@othernetwork.com> [Mike E. replies to Tom B., includes only a ref to his msg] From: Mike E. Subject: Re[1]: This is a new thread about smurfs Message-ID: <def123@thisdomain.com> References: <abc123@mynetwork.com>

Next Page