Created
January 19, 2016 09:45
-
-
Save crearo/4c8e15c89d4f895e2987 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void fetchContacts() { | |
ZcsService zcsService = new ZcsService("https://webmail.daiict.ac.in/service/soap", 2, true); | |
AccountSelector accountSelector = new AccountSelector(); | |
accountSelector.setBy(AccountBy.OPT5_NAME); | |
accountSelector.setValue(username); | |
AuthRequest authRequest = new AuthRequest(); | |
authRequest.setAccount(accountSelector); | |
authRequest.setCsrfTokenSecured(true); | |
authRequest.setPersistAuthTokenCookie(true); | |
authRequest.setPassword(pwd); | |
try { | |
AuthResponse authResponse = zcsService.authRequest(authRequest, null); | |
HeaderAccountInfo headerAccountInfo = new HeaderAccountInfo(); | |
headerAccountInfo.setValue(username); | |
headerAccountInfo.setBy("name"); | |
HeaderContext headerContext = new HeaderContext(); | |
headerContext.setAccount(headerAccountInfo); | |
headerContext.setAuthToken(authResponse.getAuthToken()); | |
headerContext.setCsrfToken(authResponse.getCsrfToken()); | |
zimbra.Context context = new zimbra.Context(); | |
context.setContext(headerContext); | |
zimbramail.AutoCompleteRequest autoCompleteRequest = new zimbramail.AutoCompleteRequest(); | |
autoCompleteRequest.setName(searchText); | |
autoCompleteRequest.setNeedExp(true); | |
AutoCompleteResponse autoCompleteResponse = zcsService.autoCompleteRequest(autoCompleteRequest, context); | |
AutoCompleteMatch autoCompleteMatch[] = autoCompleteResponse.getMatch(); | |
addresses = new String[autoCompleteMatch.length]; | |
for (int i = 0; i < addresses.length; i++) { | |
addresses[i] = autoCompleteMatch[i].getEmail(); | |
} | |
result = true; | |
} catch (IOException e) { | |
addresses = null; | |
e.printStackTrace(); | |
result = false; | |
} catch (XmlPullParserException e) { | |
addresses = null; | |
e.printStackTrace(); | |
result = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment