1b7b0e3effcbf54a2e3611460e8695e4b2076140
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / android / intent.cpp
1 /*
2  * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3, as published
6  * by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranties of
10  * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11  * PURPOSE.  See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17
18 #include "anbox/android/intent.h"
19
20 #include <ostream>
21
22 namespace anbox {
23 namespace android {
24 bool Intent::valid() const {
25   // At the moment we only support component+package for intents
26   // (see android/service/android_api_skeleton.cpp for more details)
27   return !(component.empty() && package.empty());
28 }
29
30 std::ostream &operator<<(std::ostream &out, const Intent &intent) {
31   out << "[";
32   if (!intent.action.empty())
33     out << " " << "action=" << intent.action << " ";
34   if (!intent.uri.empty())
35     out << " " << "uri=" << intent.uri << " ";
36   if (!intent.type.empty())
37     out << " " << "type=" << intent.type  << " ";
38   if (intent.flags > 0)
39     out << " " << "flags=" << intent.flags  << " ";
40   if (!intent.package.empty())
41     out << " " << "package=" << intent.package << " ";
42   if (!intent.component.empty())
43     out << "component=" << intent.component << " ";
44   if (intent.categories.size() > 0) {
45     out << "categories=[ ";
46     for (const auto &category : intent.categories) out << category << " ";
47     out << "] ";
48   }
49   out << "]";
50   return out;
51 }
52 }  // namespace android
53 }  // namespace anbox