10e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org/*
20e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * libjingle
30e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Copyright 2004--2005, Google Inc.
40e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *
50e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Redistribution and use in source and binary forms, with or without
60e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * modification, are permitted provided that the following conditions are met:
70e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *
80e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *  1. Redistributions of source code must retain the above copyright notice,
90e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *     this list of conditions and the following disclaimer.
100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *  2. Redistributions in binary form must reproduce the above copyright notice,
110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *     this list of conditions and the following disclaimer in the documentation
120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *     and/or other materials provided with the distribution.
130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *  3. The name of the author may not be used to endorse or promote products
140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *     derived from this software without specific prior written permission.
150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org *
160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org */
270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
28b9518277716cf5081d3058d86ab7d98b78f696e8pbos@webrtc.org#include <stdio.h>
29b9518277716cf5081d3058d86ab7d98b78f696e8pbos@webrtc.org
300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <iostream>
310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/xmpp/constants.h"
330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/xmpp/xmppclientsettings.h"
340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/xmpp/xmppengine.h"
350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/xmpp/xmppthread.h"
36cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "webrtc/base/thread.h"
370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgint main(int argc, char **argv) {
390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::cout << "OAuth Access Token: ";
400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::string auth_token;
410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::getline(std::cin, auth_token);
420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::cout << "User Name: ";
440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::string username;
450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::getline(std::cin, username);
460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Start xmpp on a different thread
480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  buzz::XmppThread thread;
490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  thread.Start();
500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  buzz::XmppClientSettings xcs;
520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  xcs.set_user(username.c_str());
530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  xcs.set_host("gmail.com");
540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  xcs.set_use_tls(buzz::TLS_DISABLED);
550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  xcs.set_auth_token(buzz::AUTH_MECHANISM_OAUTH2,
560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                     auth_token.c_str());
572a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  xcs.set_server(rtc::SocketAddress("talk.google.com", 5222));
580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  thread.Login(xcs);
590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Use main thread for console input
610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::string line;
620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  while (std::getline(std::cin, line)) {
630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    if (line == "quit")
640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org      break;
650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  }
660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  return 0;
670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
68