1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
|
/**
* @file llappviewerlinux.cpp
* @brief The LLAppViewerLinux class definitions
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llappviewerlinux.h"
#include "llcommandlineparser.h"
#include "lldiriterator.h"
#include "llurldispatcher.h" // SLURL from other app instance
#include "llviewernetwork.h"
#include "llviewercontrol.h"
#include "llwindowsdl.h"
#include "llmd5.h"
#include "llfindlocale.h"
#include <exception>
#if LL_DBUS_ENABLED
# include "llappviewerlinux_api_dbus.h"
// regrettable hacks to give us better runtime compatibility with older systems inside llappviewerlinux_api.h:
#define llg_return_if_fail(COND) do{if (!(COND)) return;}while(0)
#undef g_return_if_fail
#define g_return_if_fail(COND) llg_return_if_fail(COND)
// The generated API
# include "llappviewerlinux_api.h"
#endif
namespace
{
int gArgC = 0;
char **gArgV = NULL;
void (*gOldTerminateHandler)() = NULL;
}
// Initialize static members
guint32 LLAppViewerLinux::sPowerInhibitCookie = 0;
bool LLAppViewerLinux::sPowerInhibitActive = false;
static void exceptionTerminateHandler()
{
// reinstall default terminate() handler in case we re-terminate.
if (gOldTerminateHandler) std::set_terminate(gOldTerminateHandler);
// treat this like a regular viewer crash, with nice stacktrace etc.
long *null_ptr;
null_ptr = 0;
*null_ptr = 0xDEADBEEF; //Force an exception that will trigger breakpad.
// we've probably been killed-off before now, but...
gOldTerminateHandler(); // call old terminate() handler
}
int main( int argc, char **argv )
{
// Call Tracy first thing to have it allocate memory
// https://github.com/wolfpld/tracy/issues/196
LL_PROFILER_FRAME_END;
LL_PROFILER_SET_THREAD_NAME("App");
gArgC = argc;
gArgV = argv;
LLAppViewer* viewer_app_ptr = new LLAppViewerLinux();
// install unexpected exception handler
gOldTerminateHandler = std::set_terminate(exceptionTerminateHandler);
bool ok = viewer_app_ptr->init();
if(!ok)
{
LL_WARNS() << "Application init failed." << LL_ENDL;
return -1;
}
// Run the application main loop
while (! viewer_app_ptr->frame())
{}
if (!LLApp::isError())
{
//
// We don't want to do cleanup here if the error handler got called -
// the assumption is that the error handler is responsible for doing
// app cleanup if there was a problem.
//
viewer_app_ptr->cleanup();
}
delete viewer_app_ptr;
viewer_app_ptr = NULL;
return 0;
}
LLAppViewerLinux::LLAppViewerLinux()
{
}
LLAppViewerLinux::~LLAppViewerLinux()
{
// Clean up any power management inhibition on exit
if (sPowerInhibitActive)
{
uninhibitPowerManagement();
}
}
bool LLAppViewerLinux::init()
{
// g_thread_init() must be called before *any* use of glib, *and*
// before any mutexes are held, *and* some of our third-party
// libraries likes to use glib functions; in short, do this here
// really early in app startup!
if (!g_thread_supported ()) g_thread_init (NULL);
bool success = LLAppViewer::init();
#if LL_SEND_CRASH_REPORTS
if (success)
{
LLAppViewer* pApp = LLAppViewer::instance();
pApp->initCrashReporting();
}
#endif
return success;
}
bool LLAppViewerLinux::restoreErrorTrap()
{
// *NOTE:Mani there is a case for implementing this on the mac.
// Linux doesn't need it to my knowledge.
return true;
}
/////////////////////////////////////////
#if LL_DBUS_ENABLED
typedef struct
{
GObjectClass parent_class;
} ViewerAppAPIClass;
static void viewerappapi_init(ViewerAppAPI *server);
static void viewerappapi_class_init(ViewerAppAPIClass *klass);
///
// regrettable hacks to give us better runtime compatibility with older systems in general
static GType llg_type_register_static_simple_ONCE(GType parent_type,
const gchar *type_name,
guint class_size,
GClassInitFunc class_init,
guint instance_size,
GInstanceInitFunc instance_init,
GTypeFlags flags)
{
static GTypeInfo type_info;
memset(&type_info, 0, sizeof(type_info));
type_info.class_size = class_size;
type_info.class_init = class_init;
type_info.instance_size = instance_size;
type_info.instance_init = instance_init;
return g_type_register_static(parent_type, type_name, &type_info, flags);
}
#define llg_intern_static_string(S) (S)
#define g_intern_static_string(S) llg_intern_static_string(S)
#define g_type_register_static_simple(parent_type, type_name, class_size, class_init, instance_size, instance_init, flags) llg_type_register_static_simple_ONCE(parent_type, type_name, class_size, class_init, instance_size, instance_init, flags)
G_DEFINE_TYPE(ViewerAppAPI, viewerappapi, G_TYPE_OBJECT);
void viewerappapi_class_init(ViewerAppAPIClass *klass)
{
}
static bool dbus_server_init = false;
void viewerappapi_init(ViewerAppAPI *server)
{
// Connect to the default DBUS, register our service/API.
if (!dbus_server_init)
{
GError *error = NULL;
server->connection = lldbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (server->connection)
{
lldbus_g_object_type_install_info(viewerappapi_get_type(), &dbus_glib_viewerapp_object_info);
lldbus_g_connection_register_g_object(server->connection, VIEWERAPI_PATH, G_OBJECT(server));
DBusGProxy *serverproxy = lldbus_g_proxy_new_for_name(server->connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
guint request_name_ret_unused;
// akin to org_freedesktop_DBus_request_name
if (lldbus_g_proxy_call(serverproxy, "RequestName", &error, G_TYPE_STRING, VIEWERAPI_SERVICE, G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &request_name_ret_unused, G_TYPE_INVALID))
{
// total success.
dbus_server_init = true;
}
else
{
LL_WARNS() << "Unable to register service name: " << error->message << LL_ENDL;
}
g_object_unref(serverproxy);
}
else
{
g_warning("Unable to connect to dbus: %s", error->message);
}
if (error)
g_error_free(error);
}
}
gboolean viewer_app_api_GoSLURL(ViewerAppAPI *obj, gchar *slurl, gboolean **success_rtn, GError **error)
{
bool success = false;
LL_INFOS() << "Was asked to go to slurl: " << slurl << LL_ENDL;
std::string url = slurl;
LLMediaCtrl* web = NULL;
const bool trusted_browser = false;
if (LLURLDispatcher::dispatch(url, "", web, trusted_browser))
{
// bring window to foreground, as it has just been "launched" from a URL
// todo: hmm, how to get there from here?
//xxx->mWindow->bringToFront();
success = true;
}
*success_rtn = g_new (gboolean, 1);
(*success_rtn)[0] = (gboolean)success;
return TRUE; // the invokation succeeded, even if the actual dispatch didn't.
}
///
//virtual
bool LLAppViewerLinux::initSLURLHandler()
{
if (!grab_dbus_syms(DBUSGLIB_DYLIB_DEFAULT_NAME))
{
return false; // failed
}
g_type_init();
//ViewerAppAPI *api_server = (ViewerAppAPI*)
g_object_new(viewerappapi_get_type(), NULL);
return true;
}
//virtual
bool LLAppViewerLinux::sendURLToOtherInstance(const std::string& url)
{
if (!grab_dbus_syms(DBUSGLIB_DYLIB_DEFAULT_NAME))
{
return false; // failed
}
bool success = false;
DBusGConnection *bus;
GError *error = NULL;
g_type_init();
bus = lldbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (bus)
{
gboolean rtn = FALSE;
DBusGProxy *remote_object =
lldbus_g_proxy_new_for_name(bus, VIEWERAPI_SERVICE, VIEWERAPI_PATH, VIEWERAPI_INTERFACE);
if (lldbus_g_proxy_call(remote_object, "GoSLURL", &error,
G_TYPE_STRING, url.c_str(), G_TYPE_INVALID,
G_TYPE_BOOLEAN, &rtn, G_TYPE_INVALID))
{
success = rtn;
}
else
{
LL_INFOS() << "Call-out to other instance failed (perhaps not running): " << error->message << LL_ENDL;
}
g_object_unref(G_OBJECT(remote_object));
}
else
{
LL_WARNS() << "Couldn't connect to session bus: " << error->message << LL_ENDL;
}
if (error)
g_error_free(error);
return success;
}
#else // LL_DBUS_ENABLED
bool LLAppViewerLinux::initSLURLHandler()
{
return false; // not implemented without dbus
}
bool LLAppViewerLinux::sendURLToOtherInstance(const std::string& url)
{
return false; // not implemented without dbus
}
#endif // LL_DBUS_ENABLED
void LLAppViewerLinux::setOSHibernationMode(eHibernationMode mode)
{
if (mode == LL_HIBERNATE_MODE_DEFAULT)
{
// Allow OS to sleep/hibernate - remove any inhibition
if (sPowerInhibitActive)
{
uninhibitPowerManagement();
LL_INFOS("OS") << "Permitted OS hibernation/sleep" << LL_ENDL;
}
}
else if (mode == LL_HIBERNATE_MODE_PREVENT)
{
// Prevent system sleep, but allow display to turn off
// Release any existing inhibition first to allow mode switching
if (sPowerInhibitActive)
{
uninhibitPowerManagement();
}
if (inhibitPowerManagement(false))
{
LL_INFOS("OS") << "Prevented OS hibernation/sleep, display sleep allowed" << LL_ENDL;
}
else
{
LL_WARNS("OS") << "Failed to prevent OS hibernation/sleep" << LL_ENDL;
}
}
else if (mode == LL_HIBERNATE_MODE_PREVENT_SCREEN)
{
// Prevent both system and display sleep
// Release any existing inhibition first to allow mode switching
if (sPowerInhibitActive)
{
uninhibitPowerManagement();
}
if (inhibitPowerManagement(true))
{
LL_INFOS("OS") << "Prevented OS hibernation/sleep and display sleep" << LL_ENDL;
}
else
{
LL_WARNS("OS") << "Failed to prevent OS hibernation/sleep and display sleep" << LL_ENDL;
}
}
}
// TODO: This is AI Generated!!!, needs review and testing.
bool LLAppViewerLinux::inhibitPowerManagement(bool inhibit_display)
{
#if LL_DBUS_ENABLED
// Try to use D-Bus to inhibit power management via various desktop environment APIs
// This works with GNOME, KDE, XFCE, and most modern Linux desktop environments
if (!grab_dbus_syms(DBUSGLIB_DYLIB_DEFAULT_NAME))
{
LL_WARNS("OS") << "Failed to load D-Bus symbols for power management" << LL_ENDL;
return false;
}
GError* error = nullptr;
DBusGConnection* bus = lldbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (!bus)
{
LL_WARNS("OS") << "Failed to connect to D-Bus session bus: "
<< (error ? error->message : "unknown error") << LL_ENDL;
if (error)
g_error_free(error);
return false;
}
// Try multiple power management services in order of preference
// 1. org.freedesktop.PowerManagement (older standard)
// 2. org.gnome.SessionManager (GNOME)
// 3. org.kde.Solid.PowerManagement (KDE)
const char* services[] = {
"org.freedesktop.PowerManagement",
"org.gnome.SessionManager",
"org.kde.Solid.PowerManagement"
};
const char* paths[] = {
"/org/freedesktop/PowerManagement/Inhibit",
"/org/gnome/SessionManager",
"/org/kde/Solid/PowerManagement"
};
const char* interfaces[] = {
"org.freedesktop.PowerManagement.Inhibit",
"org.gnome.SessionManager",
"org.kde.Solid.PowerManagement"
};
const char* methods[] = {
"Inhibit",
"Inhibit",
"inhibit"
};
bool success = false;
for (int i = 0; i < 3 && !success; ++i)
{
DBusGProxy* proxy = lldbus_g_proxy_new_for_name(
bus,
services[i],
paths[i],
interfaces[i]
);
if (!proxy)
continue;
error = nullptr;
guint32 cookie = 0;
if (i == 0) // freedesktop.PowerManagement
{
// Inhibit(application_name: s, reason: s) -> cookie: u
success = lldbus_g_proxy_call(
proxy,
methods[i],
&error,
G_TYPE_STRING, "Second Life Viewer",
G_TYPE_STRING, inhibit_display ?
"Viewer active - preventing system and display sleep" :
"Viewer active - preventing system sleep",
G_TYPE_INVALID,
G_TYPE_UINT, &cookie,
G_TYPE_INVALID
);
}
else if (i == 1) // GNOME SessionManager
{
// Inhibit(app_id: s, toplevel_xid: u, reason: s, flags: u) -> cookie: u
// flags: 4 = suspend, 8 = idle (display), 12 = both
guint32 flags = inhibit_display ? 12 : 4;
success = lldbus_g_proxy_call(
proxy,
methods[i],
&error,
G_TYPE_STRING, "SecondLifeViewer",
G_TYPE_UINT, 0, // toplevel_xid (0 = none)
G_TYPE_STRING, inhibit_display ?
"Viewer active - preventing system and display sleep" :
"Viewer active - preventing system sleep",
G_TYPE_UINT, flags,
G_TYPE_INVALID,
G_TYPE_UINT, &cookie,
G_TYPE_INVALID
);
}
else if (i == 2) // KDE Solid
{
// Different method signature for KDE
success = lldbus_g_proxy_call(
proxy,
methods[i],
&error,
G_TYPE_INVALID,
G_TYPE_INT, &cookie,
G_TYPE_INVALID
);
}
if (success)
{
sPowerInhibitCookie = cookie;
sPowerInhibitActive = true;
LL_INFOS("OS") << "Successfully inhibited power management using "
<< services[i] << LL_ENDL;
}
else if (error)
{
LL_DEBUGS("OS") << "Failed to inhibit via " << services[i]
<< ": " << error->message << LL_ENDL;
g_error_free(error);
error = nullptr;
}
g_object_unref(proxy);
}
return success;
#else // !LL_DBUS_ENABLED
LL_WARNS("OS") << "Power management control not available - D-Bus support not enabled" << LL_ENDL;
return false;
#endif
}
void LLAppViewerLinux::uninhibitPowerManagement()
{
#if LL_DBUS_ENABLED
if (!sPowerInhibitActive || sPowerInhibitCookie == 0)
{
return;
}
if (!grab_dbus_syms(DBUSGLIB_DYLIB_DEFAULT_NAME))
{
LL_WARNS("OS") << "Failed to load D-Bus symbols for power management uninhibit" << LL_ENDL;
return;
}
GError* error = nullptr;
DBusGConnection* bus = lldbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (!bus)
{
if (error)
g_error_free(error);
return;
}
// Try to uninhibit using all services that might have been used
const char* services[] = {
"org.freedesktop.PowerManagement",
"org.gnome.SessionManager",
"org.kde.Solid.PowerManagement"
};
const char* paths[] = {
"/org/freedesktop/PowerManagement/Inhibit",
"/org/gnome/SessionManager",
"/org/kde/Solid/PowerManagement"
};
const char* interfaces[] = {
"org.freedesktop.PowerManagement.Inhibit",
"org.gnome.SessionManager",
"org.kde.Solid.PowerManagement"
};
const char* methods[] = {
"UnInhibit",
"Uninhibit",
"uninhibit"
};
bool success = false;
for (int i = 0; i < 3; ++i)
{
DBusGProxy* proxy = lldbus_g_proxy_new_for_name(
bus,
services[i],
paths[i],
interfaces[i]
);
if (!proxy)
continue;
error = nullptr;
if (lldbus_g_proxy_call(
proxy,
methods[i],
&error,
G_TYPE_UINT, sPowerInhibitCookie,
G_TYPE_INVALID,
G_TYPE_INVALID))
{
success = true;
LL_INFOS("OS") << "Successfully uninhibited power management using "
<< services[i] << LL_ENDL;
}
else if (error)
{
LL_DEBUGS("OS") << "Failed to uninhibit via " << services[i]
<< ": " << error->message << LL_ENDL;
g_error_free(error);
error = nullptr;
}
g_object_unref(proxy);
if (success)
break;
}
sPowerInhibitCookie = 0;
sPowerInhibitActive = false;
#endif // LL_DBUS_ENABLED
}
void LLAppViewerLinux::initCrashReporting(bool reportFreeze)
{
std::string cmd =gDirUtilp->getExecutableDir();
cmd += gDirUtilp->getDirDelimiter();
#if LL_LINUX
cmd += "linux-crash-logger.bin";
#else
# error Unknown platform
#endif
std::stringstream pid_str;
pid_str << LLApp::getPid();
std::string logdir = gDirUtilp->getExpandedFilename(LL_PATH_DUMP, "");
std::string appname = gDirUtilp->getExecutableFilename();
// launch the actual crash logger
const char * cmdargv[] =
{cmd.c_str(),
"-user",
(char*)LLGridManager::getInstance()->getGridId().c_str(),
"-name",
LLAppViewer::instance()->getSecondLifeTitle().c_str(),
"-pid",
pid_str.str().c_str(),
"-dumpdir",
logdir.c_str(),
"-procname",
appname.c_str(),
NULL};
fflush(NULL);
pid_t pid = fork();
if (pid == 0)
{ // child
execv(cmd.c_str(), (char* const*) cmdargv); /* Flawfinder: ignore */
LL_WARNS() << "execv failure when trying to start " << cmd << LL_ENDL;
_exit(1); // avoid atexit()
}
else
{
if (pid > 0)
{
// DO NOT wait for child proc to die; we want
// the logger to outlive us while we quit to
// free up the screen/keyboard/etc.
////int childExitStatus;
////waitpid(pid, &childExitStatus, 0);
}
else
{
LL_WARNS() << "fork failure." << LL_ENDL;
}
}
// Sometimes signals don't seem to quit the viewer. Also, we may
// have been called explicitly instead of from a signal handler.
// Make sure we exit so as to not totally confuse the user.
//_exit(1); // avoid atexit(), else we may re-crash in dtors.
}
bool LLAppViewerLinux::beingDebugged()
{
static enum {unknown, no, yes} debugged = unknown;
if (debugged == unknown)
{
pid_t ppid = getppid();
char *name;
int ret;
ret = asprintf(&name, "/proc/%d/exe", ppid);
if (ret != -1)
{
char buf[1024];
ssize_t n;
n = readlink(name, buf, sizeof(buf) - 1);
if (n != -1)
{
char *base = strrchr(buf, '/');
buf[n + 1] = '\0';
if (base == NULL)
{
base = buf;
} else {
base += 1;
}
if (strcmp(base, "gdb") == 0)
{
debugged = yes;
}
}
free(name);
}
}
return debugged == yes;
}
void LLAppViewerLinux::initLoggingAndGetLastDuration()
{
// Remove the last stack trace, if any
// This file is no longer created, since the move to Google Breakpad
// The code is left here to clean out any old state in the log dir
std::string old_stack_file =
gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log");
LLFile::remove(old_stack_file);
LLAppViewer::initLoggingAndGetLastDuration();
}
bool LLAppViewerLinux::initParseCommandLine(LLCommandLineParser& clp)
{
if (!clp.parseCommandLine(gArgC, gArgV))
{
return false;
}
// Find the system language.
FL_Locale *locale = NULL;
FL_Success success = FL_FindLocale(&locale, FL_MESSAGES);
if (success != 0)
{
if (success >= 2 && locale->lang) // confident!
{
LL_INFOS("AppInit") << "Language " << ll_safe_string(locale->lang) << LL_ENDL;
LL_INFOS("AppInit") << "Location " << ll_safe_string(locale->country) << LL_ENDL;
LL_INFOS("AppInit") << "Variant " << ll_safe_string(locale->variant) << LL_ENDL;
LLControlVariable* c = gSavedSettings.getControl("SystemLanguage");
if(c)
{
c->setValue(std::string(locale->lang), false);
}
}
}
FL_FreeLocale(&locale);
return true;
}
std::string LLAppViewerLinux::generateSerialNumber()
{
char serial_md5[MD5HEX_STR_SIZE];
serial_md5[0] = 0;
std::string best;
std::string uuiddir("/dev/disk/by-uuid/");
// trawl /dev/disk/by-uuid looking for a good-looking UUID to grab
std::string this_name;
LLDirIterator iter(uuiddir, "*");
while (iter.next(this_name))
{
if (this_name.length() > best.length() ||
(this_name.length() == best.length() &&
this_name > best))
{
// longest (and secondarily alphabetically last) so far
best = this_name;
}
}
// we don't return the actual serial number, just a hash of it.
LLMD5 md5( reinterpret_cast<const unsigned char*>(best.c_str()) );
md5.hex_digest(serial_md5);
return serial_md5;
}
|