Description
-
Searches for contacts.
Return Type
-
None
Syntax
-
object.Search Service, Query
The Search Method syntax has these parts:
| object |
An expression evaluating to an object
of type XMPPContacts. |
| Service |
Required. A
XMPPService value.
Specifies which service (of type
CatDirectory) to use to perform the search.. |
| Query |
Required. A XMPPVars value. Contains search
query, as required by the server. Can be set to
NULL (Nothing
in VB). |
Remarks
-
Search method will send request to the server to perform various
searches, usually to search for contacts that exist on the server.
When search completes,
ContactSearchDone event will fire with the results.
-
-
In order to obtain required service to perform the search, you
should check Services
of CatDirectory identity. You can also
use
ServicesFiltered(CatDirectory) to
obtain the list the easier way. Once you choose the service, you can
perform complete search in two steps:
-
-
1. First step is to call Search method with Query argument set to
NULL (Nothing in VB), so that server provides us with the "Search
Form" which can be filled by the user, something like this:
- Dim DirService As XMPPService
Set DirService = wodXMPP1.ServicesFiltered(CatDirectory).Item(0)
'first one available
wodXMPP1.Contacts.Search DirService, Nothing
-
2. When above code completes,
ContactSearchDone event fires containing the "Search Form"
which can be shown on the screen. To be sure server provided the
form, you can check XMPPVars.Type
property which should contain 'VarForm'
value. User then enters search details, and you perform the search
again, but this time Query will contain values entered by the user:
- Private Sub
wodXMPP1_ContactSearchDone(ByVal Service As
WODXMPPCOMLib.IXMPPService, ByVal Items As
WODXMPPCOMLib.IXMPPVars)
If Items.Type = VarForm Then
Dim fok As
Boolean
fok =
Items.Show("") ' user clicked on OK?
If fok Then
wodXMPP1.Contacts.Search Service, Items '
real search, with the data
End If
End Sub
-
-
3. When real search completes,
ContactSearchDone event fires again, containing search
results. Since data is received as multiple-rows data (tabular),
wodXMPP will create XMPPVars collection
again, but each Item will contain "subitems" too - one such item for
each row. Data will be returned as VarReport
in XMPPVars.Type.
For example, you can then view search results like this:
- Private Sub wodXMPP1_ContactSearchDone(ByVal
Service As WODXMPPCOMLib.IXMPPService, ByVal Items As
WODXMPPCOMLib.IXMPPVars)
If Items.Type = VarReport Then
Dim i As
Integer
For i = 0 To
Items("jid").SubCount - 1
Debug.Print Items("jid").SubValue(i) ' show
only JID subitems
Next i
End If
End Sub
-
-
Youcan skip 1st and 2nd step if you already know what kind of search
query is needed and you have created XMPPVars manually. For example,
on most servers, this automated search will work, which you can then
use as explained in 3rd step:
- Dim DirService As XMPPService
Set DirService = wodXMPP1.ServicesFiltered(CatDirectory).Item(0)
'first one available
Dim Query As New XMPPVars
Query.Add("jid").Value = "myfriend*"
wodXMPP1.Contacts.Search DirService, Query
-
.
|