📄 398-401.html
字号:
<!-- END SUB HEADER -->
<!--Begin Content Column -->
<FONT FACE="Arial,Helvetica" SIZE="-1">
To access the contents, click the chapter and section titles.
</FONT>
<P>
<B>Essential Windows CE Application Programming</B>
<FONT SIZE="-1">
<BR>
<I>(Publisher: John Wiley & Sons, Inc.)</I>
<BR>
Author(s): Robert Burdick
<BR>
ISBN: 0471327476
<BR>
Publication Date: 03/01/99
</FONT>
<P>
<form name="Search" method="GET" action="http://search.earthweb.com/search97/search_redir.cgi">
<INPUT TYPE="hidden" NAME="Action" VALUE="Search">
<INPUT TYPE="hidden" NAME="SearchPage" VALUE="http://search.earthweb.com/search97/samples/forms/srchdemo.htm">
<INPUT TYPE="hidden" NAME="Collection" VALUE="ITK">
<INPUT TYPE="hidden" NAME="ResultTemplate" VALUE="itk-simple-intrabook.hts">
<INPUT TYPE="hidden" NAME="ViewTemplate" VALUE="view.hts">
<font face="arial, helvetica" size=2><b>Search this book:</b></font><br>
<INPUT NAME="queryText" size=50 VALUE=""> <input type="submit" name="submitbutton" value="Go!">
<INPUT type=hidden NAME="section_on" VALUE="on">
<INPUT type=hidden NAME="section" VALUE="http://www.itknowledge.com/reference/standard/0471327476/">
</form>
<!-- Empty Reference Subhead -->
<!--ISBN=0471327476//-->
<!--TITLE=Essential Windows CE Application Programming//-->
<!--AUTHOR=Robert Burdick//-->
<!--PUBLISHER=John Wiley & Sons, Inc.//-->
<!--IMPRINT=Wiley Computer Publishing//-->
<!--CHAPTER=14//-->
<!--PAGES=398-401//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="396-398.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="401-402.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B>Other Device Service Provider Functions</B></FONT></P>
<P>We will briefly describe the functions <I>InitObjType</I> and <I>GetObjTypeInfo,</I> which are exported by a device service provider. <I>ReportStatus</I> is an optional function and is not covered.</P>
<P><FONT SIZE="+1"><B><I>InitObjType</I></B></FONT></P>
<P>The function <I>InitObjType</I> is used to create the service provider’s IReplObjHandler interface instance. It is also called when the service provider DLL is unloaded when ActiveSync terminates. This gives the service provider a chance to free any resources it may have allocated.</P>
<!-- CODE SNIP //-->
<PRE>
BOOL InitObjType(lpszObjType, ppObjHandler, uPartnerBit);
</PRE>
<!-- END CODE SNIP //-->
<P><I>lpszObjType</I> is the name of the object type being initialized. In the case of the phone list application, this is “PhoneApp.” This string will be NULL if <I>InitObjType</I> is being called during termination.</P>
<P><I>ppObjHandler</I> is used as an output parameter. It is used to return a pointer to the service provider’s IReplObjHandler interface instance. <I>uPartnerBit</I> indicates which partner the desktop computer is connected as. A value of 1 indicates it is partner 1, while 2 indicates the desktop is connected as partner 2.</P>
<P><I>InitObjType</I> returns TRUE if successful, and FALSE if unsuccessful.</P>
<P>The phone list device service provider uses <I>InitObjType</I> to store the partner bit in a global variable and to return the IReplObjHandler instance to the service manager:</P>
<!-- CODE //-->
<PRE>
BOOL InitObjType(LPWSTR lpszObjType,
IReplObjHandler** ppObjHandler,
UINT uPartnerBit)
{
if (lpszObjType == NULL)
{
//Free resources if necessary
return (TRUE);
}
*ppObjHandler = new CDataHandler;
v_uPartnerBit = uPartnerBit;
return (TRUE);
}
</PRE>
<!-- END CODE //-->
<P><FONT SIZE="+1"><B><I>GetObjTypeInfo</I></B></FONT></P>
<P>This function is called by the service manager to get information about a particular type of data synchronized by the device service provider.
</P>
<!-- CODE SNIP //-->
<PRE>
BOOL GetObjTypeInfo(pObjTypeInfo);
</PRE>
<!-- END CODE SNIP //-->
<P>The parameter is a pointer to an OBJTYPEINFO structure. This structure is used to tell the service provider which data type the service manager wants information about. The service provider fills in various members of this structure to supply the requested information.
</P>
<!-- CODE //-->
<PRE>
typedef struct tagObjTypeInfo {
UINT cbStruct;
OBJTYPENAMEW szObjType;
UINT uFlags;
WCHAR szName[ 80 ]
UINT cObjects;
UINT cbAllObj;
FILETIME ftLastModified
} OBJTPYEINFO, *POBJTYPEINFO;
</PRE>
<!-- END CODE //-->
<P><I>cbStruct</I> contains the byte size of the structure. <I>uFlags</I> is reserved by Windows CE and is therefore not used.</P>
<P><I>szObjType</I> is a string containing the name of the data type for which information is requested.</P>
<P>The service provider uses the other four members to report data type information to the service manager. <I>szName</I> is the name of the file or database containing the data store objects. <I>cObjects</I> is the number of objects of the requested type, and <I>cbAllObj</I> is the number of bytes used to store these objects. Finally, <I>ftLastModified</I> reports the last time any of the objects was modified.</P>
<P>For example, the phone list device service provider implements <I>GetObjTypeInfo</I> as follows:</P>
<!-- CODE //-->
<PRE>
BOOL GetObjTypeInfo(POBJTYPEINFO pInfo)
{
CEOIDINFO oidInfo;
//g_oidDB is the global handle to the phone list database
CeOidGetInfo(g_oidDB, &oidInfo);
lstrcpy(pInfo->szName, oidInfo.infDatabase.szDbaseName);
pInfo->cObjects = oidInfo.infDatabase.wNumRecords;
pInfo->cbAllObj = oidInfo.infDatabase.dwSize;
pInfo->ftLastModified = oidInfo.infDatabase.ftLastModified;
return (TRUE);
}
</PRE>
<!-- END CODE //-->
<H3><A NAME="Heading14"></A><FONT COLOR="#000077">Conflict Resolution</FONT></H3>
<P>Thus far in our discussion of data synchronization, we have talked about items that are changed either on the desktop computer or on the Windows CE device and then transferred to the other platform.
</P>
<P>But what happens if the same data store object is modified on both the desktop and the device, and then the user attempts to synchronize? The ActiveSync service manager includes functionality for resolving such data conflicts. And as with all other synchronization operations, the service manager asks for help by calling various service provider methods.</P>
<P><FONT SIZE="+1"><B>Creating a Conflict</B></FONT></P>
<P>To demonstrate the ActiveSync conflict resolution scheme, I created the phone list entry shown in Figure 14.8 on my desktop PC.
</P>
<P><A NAME="Fig8"></A><A HREF="javascript:displayWindow('images/14-08.jpg',640,179 )"><IMG SRC="images/14-08t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/14-08.jpg',640,179)"><FONT COLOR="#000077"><B>Figure 14.8</B></FONT></A> The original phone entry.</P>
<P>I then synchronized with my Handheld PC to put this entry in the Handheld PC data store. Next, I changed the entry on both the desktop and the device. On the desktop, I changed the last name to “Users”. On the device, I changed the first name to “Same”. I then re-synchronized, and ActiveSync displayed the dialog box shown in Figure 14.9.
</P>
<P><A NAME="Fig9"></A><A HREF="javascript:displayWindow('images/14-09.jpg',423,205 )"><IMG SRC="images/14-09t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/14-09.jpg',423,205)"><FONT COLOR="#000077"><B>Figure 14.9</B></FONT></A> The conflict resolution dialog box.</P>
<P>This conflict resolution dialog box is implemented by the ActiveSync service manager. It allows the user to decide which versions of conflicting data store objects should be saved.
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="396-398.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="401-402.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<br><br>
</TD>
</TR>
</TABLE>
<table width="640" border=0 cellpadding=0 cellspacing=0>
<tr>
<td align="left" width=135><img src="/images/white.gif" width=100 height="1" alt="" border="0"></td>
<!-- END SUB FOOTER -->
<!-- all of the books have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- FOOTER -->
<td width="515" align="left" bgcolor="#FFFFFF">
<font face="arial, helvetica" size="1"><b><a href="/products.html"><font color="#006666">Products</font></a> | <a href="/contactus.html"><font color="#006666">Contact Us</font></a> | <a href="/aboutus.html"><font color="#006666">About Us</font></a> | <a href="http://www.earthweb.com/corporate/privacy.html" target="_blank"><font color="#006666">Privacy</font></a> | <a href="http://www.itmarketer.com/" target="_blank"><font color="#006666">Ad Info</font></a> | <a href="/"><font color="#006666">Home</font></a></b>
<br><br>
Use of this site is subject to certain <a href="/agreement.html">Terms & Conditions</a>, <a href="/copyright.html">Copyright © 1996-1999 EarthWeb Inc.</a><br>
All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.</font><p>
</td>
</tr>
</table>
</BODY>
</HTML>
<!-- END FOOTER -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -