send_robot_icon.cpp
Go to the documentation of this file.
1 /*
2  * Author(s):
3  * - Joël Lamotte <jlamotte@aldebaran.com>
4  *
5  * Copyright (c) 2014 Aldebaran. All rights reserved.
6  */
7 #include <iostream>
8 #include <string>
9 #include <boost/filesystem.hpp>
10 
11 #include <qi/applicationsession.hpp>
12 #include <qicore/file.hpp>
13 #include <qi/session.hpp>
14 
15 qiLogCategory("test.qi.sendRobotIcon");
16 
17 void printTranferProgress(double progress)
18 {
19  qiLogInfo() << ">>>> File Transfer Progress = " << (progress * 100.0) << "%";
20 }
21 
22 int main(int argc, char** argv)
23 {
24  qi::ApplicationSession app(argc, argv);
25  app.startSession();
26  if (argc != 2)
27  {
28  qiLogError() << "This test takes 2 arguments!";
29  return EXIT_FAILURE;
30  }
31 
32  qi::SessionPtr session = app.session();
33  if (!session->isConnected())
34  {
35  qiLogError() << "Failed to connect to the remote naoqi!";
36  return EXIT_FAILURE;
37  }
38 
39  const std::string image_file_path = argv[1];
40  qi::FilePtr imageFile = qi::openLocalFile(qi::Path(image_file_path));
41 
42  qi::ProgressNotifierPtr progressNotifier = imageFile->operationProgress();
43  progressNotifier->progress.connect(&printTranferProgress);
44 
45  qi::AnyObject alsystem = session->service("ALSystem").value();
46  if (!alsystem)
47  {
48  qiLogError() << "Failed access ALSystem service!";
49  return EXIT_FAILURE;
50  }
51 
52  qiLogInfo() << "setRobotIcon..." << std::endl;
53  alsystem.async<void>("setRobotIcon", imageFile).wait();
54  qiLogInfo() << "setRobotIcon - DONE" << std::endl;
55  app.run();
56  return EXIT_SUCCESS;
57 }
qi::ProgressNotifierPtr
qi::Object< ProgressNotifier > ProgressNotifierPtr
Pointer to a ProgressNotifier with shared/remote semantic.
Definition: file.hpp:114
printTranferProgress
void printTranferProgress(double progress)
Definition: send_robot_icon.cpp:17
imagestore.session
session
Definition: imagestore.py:68
file.hpp
qiLogCategory
qiLogCategory("test.qi.sendRobotIcon")
main
int main(int argc, char **argv)
Definition: send_robot_icon.cpp:22
qi::openLocalFile
QICORE_API FilePtr openLocalFile(const qi::Path &localPath)
Definition: fileimpl.cpp:186
file_example.app
app
Definition: file_example.py:8
qi::FilePtr
qi::Object< File > FilePtr
Pointer to a file with shared/remote semantic.
Definition: file.hpp:213


naoqi_libqicore
Author(s): Aldebaran
autogenerated on Wed Sep 14 2022 02:22:41