⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 381-385.html

📁 WindowsCE.[Essential Windows CE Application Programming].Jon Wiley & Son.zip
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</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="">&nbsp;<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=381-385//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="377-381.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="385-388.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading9"></A><FONT COLOR="#000077">Enumerating Objects</FONT></H3>
<P>The ActiveSync service manager determines whether data objects have changed by the process of <I>enumeration</I>. As with all other synchronization steps, the manager controls the enumeration process. The desktop service provider is responsible for telling the manager if objects have changed since the last synchronization.</P>
<P>Before enumeration begins, the service manager sets a bit in each object handle stored in REPL.DAT. This bit will be used to indicate whether a particular object should be deleted from the device data store during synchronization.</P>
<P>During enumeration, the service manager asks the service provider for handles to each item in the desktop data store. The service manager compares each handle returned by the service provider to the handles stored in REPL.DAT. If a matching handle is found, the delete bit is turned off, and the service manager asks the service provider if the item has changed by calling the <I>IsItemChanged</I> method of the IReplStore interface.</P>
<P>If the service provider returns TRUE from <I>IsItemChanged</I>, the service manager obtains a copy of the new item handle by calling <I>CopyObject</I>. Finally, to determine if the new item should be transferred to the Windows CE device during synchronization, the service manager calls the IReplStore method <I>IsItemReplicated</I>.</P>
<P>The object enumeration itself is accomplished with the IReplStore methods <I>FindFirstItem</I>, <I>FindNextItem</I>, and <I>FindItemClose</I>.</P>
<P><I>FindFirstItem</I> retrieves the first item from the specified folder:</P>
<!-- CODE SNIP //-->
<PRE>
  HRESULT FindFirstItem(hFolder, phItem, pfExist);
</PRE>
<!-- END CODE SNIP //-->
<P><I>hFolder</I> is an HREPLFLD handle to the folder of interest. <I>phItem</I> is used by the method to return a pointer to the HREPLITEM handle of the first item in the folder. <I>pfExist</I> is also a return value. It is a pointer to a BOOL that the service provider returns indicating whether or not there are items in the folder.</P>
<P>The <I>FindNextItem</I> function has the same signature as <I>FindFirstItem</I>. This function is called by the service manager to obtain handles to subsequent data items. The service manager calls <I>FindNextItem</I> repeatedly until the service provider returns FALSE through the <I>pfExist</I> parameter after enumerating the last item in the folder.</P>
<P>Both <I>FindFirstItem</I> and <I>FindNextItem</I> return either E_FAIL or NOERROR. A service provider returns the E_FAIL error code to indicate that an error occurred during enumeration. In such a case, the contents of the folder in question are not synchronized. NOERROR indicates that no object enumeration problems occurred.</P>
<P>Once the last item has been enumerated, the service manager calls <I>FindItemClose</I> to give the service provider the opportunity to free any resources that were used during enumeration. The definition of <I>FindItemClose</I> is:</P>
<!-- CODE SNIP //-->
<PRE>
  HRESULT FindItemClose(hFolder);
</PRE>
<!-- END CODE SNIP //-->
<P><I>hFolder</I> is the HREPLFLD handle of the folder whose items were previously enumerated.</P>
<P><FONT SIZE="+1"><B>Copying and Synchronizing Items</B></FONT></P>
<P>As mentioned previously, as items are enumerated, the service manager will copy changed data store items and ask the service provider if such items should be synchronized.
</P>
<P>Items are copied with the IReplStore method <I>CopyObject</I>:</P>
<!-- CODE SNIP //-->
<PRE>
  BOOL CopyObject(hObjSrc, hObjDst);
</PRE>
<!-- END CODE SNIP //-->
<P>The method copies the item indicated by HREPLOBJ handle <I>hObjSrc</I> to the handle <I>hObjDst</I>. It returns TRUE if the copy is successful and FALSE if the operation fails.</P>
<P>During item enumeration, handles to new items are passed to the service manager. These item handles are copied to separate handles that are stored in REPL.DAT.</P>
<P>The service provider tells the service manager that a particular new item is to be synchronized by its response to the method <I>IsItemReplicated</I>:</P>
<!-- CODE SNIP //-->
<PRE>
  BOOL IsItemReplicated(hFolder, hItem);
</PRE>
<!-- END CODE SNIP //-->
<P><I>hItem</I> is the HREPLITEM handle of the item in question, and <I>hFolder</I> is the folder that contains the item. Desktop service providers use this method to implement rules for determining which items to replicate. If this method returns TRUE, the item will be synchronized during the next data synchronization. Returning FALSE tells the service manager not to synchronize the item.</P>
<P>The phone list application implements a simple synchronization rule using the synchronization option value that it stores with the phone entry data folder. The relevant parts of this method implementation are shown here:</P>
<!-- CODE //-->
<PRE>
  STDMETHODIMP_(BOOL) CStore::IsItemReplicated(
    HREPLFLD hFolder,
    HREPLITEM hItem)
  &#123;
    CFolder *pFolder = (CFolder *)hFolder;
    CItem  *pItem = (CItem *)hItem;
    PPHONEENTRY pEntry;
    char cLastName;
    pEntry = FindPhoneEntry(pItem-&gt;m_uid);
    if (pEntry)
    &#123;
    cLastName = pEntry-&gt;lpszLastName[0];
    &#125;
    switch (pFolder-&gt;m_uSyncOpt)
    &#123;
    case SO_ALL:
    return (TRUE);
    case SO_AM:
    return (cLastName &gt;= 'A' &#38;&#38; cLastName &lt;= 'M');
    case SO_NZ:
    return (cLastName &gt;= 'N' &#38;&#38; cLastName &lt;= 'Z');
    &#125;
    return (FALSE);
  &#125;
</PRE>
<!-- END CODE //-->
<P>The method <I>FindPhoneEntry</I> obtains the PHONEENTRY structure corresponding to the specified entry identifier from the data store contained in the <I>m_pEntries</I> data member of CStore:</P>
<!-- CODE //-->
<PRE>
   PPHONEENTRY CStore::FindPhoneEntry(
     UINT uidEntry,
     PUINT pIndex)
   &#123;
     UINT i;
     PPHONEENTRY pEntry = NULL;
     for (i = 0; i &lt; m_pEntries-&gt;cEntries; i&#43;&#43;)
     &#123;
      if (m_pEntries-&gt;rgEntries[i].uidEntry == uidEntry)
      &#123;
        break;
       &#125;
      &#125;
      if (pIndex)
      &#123;
       *pIndex = ((i &lt; m_pEntries-&gt;cEntries) ? i : -1);
      &#125;
      if (i &lt; m_pEntries-&gt;cEntries)
      &#123;
       pEntry = &#38;m_pEntries-&gt;rgEntries[i];
      &#125;
      return (pEntry);
   &#125;
</PRE>
<!-- END CODE //-->
<P>The <I>FindPhoneEntry</I> method is used extensively to retrieve the phone entry from the data store corresponding to the specified object identifier. <I>m_pEntries</I> contains all the data store entries in its <I>rgEntries</I> array. The method also returns the array index of the retrieved entry if the caller passes a non-NULL value in the <I>pIndex</I> parameter.</P>
<P>Depending on the synchronization option associated with the folder, the <I>IsItemReplicated</I> method decides if the item should be replicated. For example, the synchronization option SO_ALL means that all items are synchronized. In this case <I>IsItemReplicated</I> always returns TRUE.</P>
<P>The SO_AM option, however, means that only those items with a last name value that begins with the letters A through M are replicated. Likewise, SO_NZ means only last names beginning with N through Z get synchronized.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="377-381.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="385-388.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>&nbsp;|&nbsp; <a href="/contactus.html"><font color="#006666">Contact Us</font></a>&nbsp;|&nbsp; <a href="/aboutus.html"><font color="#006666">About Us</font></a>&nbsp;|&nbsp; <a href="http://www.earthweb.com/corporate/privacy.html" target="_blank"><font color="#006666">Privacy</font></a> &nbsp;|&nbsp; <a href="http://www.itmarketer.com/" target="_blank"><font color="#006666">Ad Info</font></a> &nbsp;|&nbsp; <a href="/"><font color="#006666">Home</font></a></b>
		<br><br>
		
		Use of this site is subject to certain <a href="/agreement.html">Terms &amp; Conditions</a>, <a href="/copyright.html">Copyright &copy; 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 + -