buffet: Add an XMPP client class
This is a relatively simple XMPP client class, which at this point,
is only used to keep the XMPP connection open to GCD.
TEST=FEATURES=test emerge buffet
BUG=brillo:95
Change-Id: I2e7c8d7352892bd7c94e630cc7872f32f2298ae4
Reviewed-on: https://chromium-review.googlesource.com/248351
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Nathan Bullock <nathanbullock@google.com>
Tested-by: Nathan Bullock <nathanbullock@google.com>
diff --git a/buffet/xmpp/xmpp_connection.h b/buffet/xmpp/xmpp_connection.h
new file mode 100644
index 0000000..741f4c8
--- /dev/null
+++ b/buffet/xmpp/xmpp_connection.h
@@ -0,0 +1,40 @@
+// Copyright 2015 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BUFFET_XMPP_XMPP_CONNECTION_H_
+#define BUFFET_XMPP_XMPP_CONNECTION_H_
+
+#include <string>
+
+#include <base/macros.h>
+
+namespace buffet {
+
+class XmppConnection {
+ public:
+ XmppConnection() {}
+ virtual ~XmppConnection();
+
+ // Initialize the XMPP client. (Connects to talk.google.com:5222).
+ virtual bool Initialize();
+
+ int GetFileDescriptor() const { return fd_; }
+
+ // Needs to be called when new data is available from the connection.
+ virtual bool Read(std::string* msg) const;
+
+ // Start talking to the XMPP server (authenticate, etc.)
+ virtual bool Write(const std::string& msg) const;
+
+ private:
+ // The file descriptor for the connection.
+ int fd_{-1};
+
+ DISALLOW_COPY_AND_ASSIGN(XmppConnection);
+};
+
+} // namespace buffet
+
+#endif // BUFFET_XMPP_XMPP_CONNECTION_H_
+