📄 385-388.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=385-388//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="381-385.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="388-392.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B><I>Setting Synchronization Options</I></B></FONT></P>
<P>As we have seen, the <I>IsItemReplicated</I> method can be used to implement synchronization rules using service provider–specific synchronization options. This section describes how the service provider obtains such options from the user.</P>
<P>To specify synchronization options for a particular installed desktop service provider, the user must choose the ActiveSync Options menu item from the Mobile Devices window Tools menu. The dialog box shown in Figure 14.5 is displayed after this menu option is selected. This dialog lists all of the installed service providers. The check box next to each indicates if the provider is active, that is, if the data corresponding to that provider is synchronized.</P>
<P><A NAME="Fig5"></A><A HREF="javascript:displayWindow('images/14-05.jpg',400,455 )"><IMG SRC="images/14-05t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/14-05.jpg',400,455)"><FONT COLOR="#000077"><B>Figure 14.5</B></FONT></A> The ActiveSync Options dialog.</P>
<P>Double-clicking on any of the service providers in the list will invoke another dialog box if the provider includes synchronization options that the user can specify. Double-clicking on PhoneApp will invoke the phone list application service provider synchronization options dialog, as shown in Figure 14.6.
</P>
<P><A NAME="Fig6"></A><A HREF="javascript:displayWindow('images/14-06.jpg',355,139 )"><IMG SRC="images/14-06t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/14-06.jpg',355,139)"><FONT COLOR="#000077"><B>Figure 14.6</B></FONT></A> Phone list service provider Synchronization Options user interface.</P>
<P>The three radio buttons correspond to the three synchronization options defined by the service provider, SO_ALL, SO_AM, and SO_NZ.
</P>
<P>A synchronization options dialog is implemented just like any other dialog box. The service provider includes the dialog template in its resource file, and implements the dialog procedure for the dialog box. The dialog box is invoked when the ActiveSync service manager calls the <I>ActivateDialog</I> method of the data store CStore interface:</P>
<!-- CODE SNIP //-->
<PRE>
HRESULT ActivateDialog(uDlg, hwndParent, hFolder, penum);
</PRE>
<!-- END CODE SNIP //-->
<P><I>hFolder</I> specifies the data folder whose options are to be specified by the service provider. <I>hwndParent</I> is the parent window that the service manager wants the provider to use as the parent of the dialog box. <I>penum</I> points to an enumerator for the items contained in <I>hFolder</I>.</P>
<P><I>uDlg</I> is an input flag indicating which dialog to invoke. Currently the only value this parameter can take is OPTIONS_DIALOG. In future versions of ActiveSync, <I>ActivateDialog</I> may be used to invoke a variety of synchronization-related user interfaces.</P>
<P>The phone list service provider implements <I>ActivateDialog</I> as follows:</P>
<!-- CODE //-->
<PRE>
STDMETHODIMP CStore::ActivateDialog(
UINT uDlg,
HWND hwndParent,
HREPLFLD hFolder,
IEnumReplItem* penum)
{
// Initialization code...
if (DialogBox(v_hInst,
MAKEINTRESOURCE(IDD_SYNCOPTIONS),
hwndParent,
(DLGPROC)dlgSyncOpt) == IDOK)
{
((CFolder *)hFolder)->m_uSyncOpt = v_uSyncOpt;
return NOERROR;
}
return RERR_CANCEL;
}
</PRE>
<!-- END CODE //-->
<P><I>v_hInst</I> contains the HINSTANCE of the service provider DLL. The dialog box procedure sets the global variable <I>v_uSyncOpt</I> to one of the synchronization options depending on which radio button is selected. If the user presses the OK button, that option is stored in the data folder.</P>
<P>ActiveSync places no restrictions on the number of synchronization options that can be defined for a particular data type. Further, your options dialog boxes may be as complicated as necessary for a user to specify the appropriate options.</P>
<H3><A NAME="Heading10"></A><FONT COLOR="#000077">Reporting Desktop Data Store Changes</FONT></H3>
<P>The previous section described how the ActiveSync service manager and desktop service provider work together to enumerate objects in the desktop data store. We said that the primary purpose of this enumeration is to aid the service manager in detecting changes in data store objects.
</P>
<P>The service manager compares the object handles returned by service provider <I>FindFirstItem</I> and <I>FindNextItem</I> calls to the handles stored in REPL.DAT. New objects are added by writing the handle and other item data to the file. But for each existing item, the service manager must determine if the item has been changed by the desktop application since the last data synchronization.</P>
<P>The service manager calls the <I>IsItemChanged</I> method on the IReplStore interface to make this determination:</P>
<!-- CODE SNIP //-->
<PRE>
BOOL IsItemChanged(hFolder, hItem, hItemComp);
</PRE>
<!-- END CODE SNIP //-->
<P><I>hFolder</I> is the handle of the folder that holds the items to be compared. <I>hItem</I> and <I>hItemComp</I> are the two items to be compared.</P>
<P>When enumerating objects, <I>hItem</I> is the handle to the item returned by a <I>FindFirstItem</I> or <I>FindNextItem</I> call, and <I>hItemComp</I> is the handle to the corresponding item from REPL.DAT. In other words, <I>hItem</I> is the current item from the desktop data store; <I>hItemComp</I> contains the attributes of the same item, as of the last synchronization.</P>
<P><I>IsItemChanged</I> can also be called by the service manager when actually transmitting data packets between the desktop and device. In such cases <I>hItemComp</I> will be NULL; the service provider compares the item in <I>hItem</I> to the corresponding item in the data store.</P>
<P>For example, the phone list service provider compares items as shown in the code below:</P>
<!-- CODE //-->
<PRE>
STDMETHODIMP_(BOOL) CStore::IsItemChanged(
HREPLFLD hFolder,
HREPLITEM hItem,
HREPLITEM hItemComp)
{
CFolder *pFolder = (CFolder *)hFolder;
CItem *pItem = (CItem *)hItem;
CItem *pItemComp = (CItem *)hItemComp;
BOOL bChanged = FALSE;
if (pItemComp)
{
bChanged = CompareFileTime(&pItem->m_ftModified,
&pItemComp->m_ftModified);
}
else
{
PPHONEENTRY pEntry;
pEntry = FindPhoneEntry(pItem->m_uid);
bChanged = pEntry &&
CompareFileTime(&pItem->m_ftModified,
&pEntry->ftLastModified);
}
return (bChanged);
}
</PRE>
<!-- END CODE //-->
<P>To determine data store item equality, the phone list application service provider simply compares the modification times of the two items. For those cases when <I>hItemComp</I> is NULL, the service provider retrieves the data store item corresponding to <I>hItem</I>. This item modification time is compared to that of <I>hItem</I>.</P>
<P>The value returned by <I>IsItemChanged</I> indicates whether the item in <I>hItem</I> has changed. A TRUE return value means the item has changed, FALSE means it has not.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="381-385.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="388-392.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 + -