Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / cloud_print / gcp20 / prototype / printer.cc
index e582826..fdbdf87 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "cloud_print/gcp20/prototype/printer.h"
 
+#include <algorithm>
 #include <limits.h>
 #include <stdio.h>
 #include <string>
@@ -37,7 +38,7 @@ const uint32 kTtlDefault = 60*60;  // in seconds
 
 const char kServiceType[] = "_privet._tcp.local";
 const char kSecondaryServiceType[] = "_printer._sub._privet._tcp.local";
-const char kServiceNamePrefixDefault[] = "first_gcp20_device";
+const char kServiceNamePrefixDefault[] = "gcp20_device_";
 const char kServiceDomainNameFormatDefault[] = "my-privet-device%d.local";
 
 const char kPrinterName[] = "Google GCP2.0 Prototype";
@@ -842,8 +843,10 @@ bool Printer::StartDnsServer() {
   uint16 port = command_line_reader::ReadHttpPort(kHttpPortDefault);
 
   std::string service_name_prefix =
-      command_line_reader::ReadServiceNamePrefix(net::IPAddressToString(ip) +
-                                                 kServiceNamePrefixDefault);
+      command_line_reader::ReadServiceNamePrefix(kServiceNamePrefixDefault +
+                                                 net::IPAddressToString(ip));
+  std::replace(service_name_prefix .begin(), service_name_prefix .end(),
+               '.', '_');
 
   std::string service_domain_name =
       command_line_reader::ReadDomainName(
@@ -851,8 +854,8 @@ bool Printer::StartDnsServer() {
                              base::RandInt(0, INT_MAX)));
 
   ServiceParameters params(kServiceType, kSecondaryServiceType,
-                           service_name_prefix,
-                           service_domain_name, ip, port);
+                           service_name_prefix, service_domain_name,
+                           ip, GetLocalIp("", true), port);
 
   return dns_server_.Start(params,
                            command_line_reader::ReadTtl(kTtlDefault),