[haiku-commits] haiku: hrev49707 - src/servers/cddb_daemon src/bin/cddb_lookup src/tests/servers/launch data

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 19 Oct 2015 21:27:43 +0200 (CEST)

hrev49707 adds 4 changesets to branch 'master'
old head: 9939ccadff24a97fac730aa99381c3425649027d
new head: d2eca26b735090011c1892465e324729a11c19d8
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=d2eca26b7350+%5E9939ccadff24

----------------------------------------------------------------------------

cfe6baf62f7e: cddb_daemon: renamed to cddb_lookup, moved to /src/bin.

* It's now a standard command line tool that is launched automatically
via the launch_daemon whenver a volume is mounted.

4e8fc45146c0: Deskbar: converted to BServer.

d9bb9513c5e9: launch_daemon: "file_exists" now resolves $HOME, and '~'.

d2eca26b7350: Moved per user post install actions to first-login script.

* The same mechanism (and the same PostInstallScript) is used for this.
* If a file first_login exists in ~/config/settings/boot, the first-login
scripts are launched, and the file removed.
* This fixes adding the deskbar tray icons even when there is no Deskbar
running yet (for example on first boot when the FirstBootPrompt
starts), or, IOW bug #12275.

[ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

28 files changed, 256 insertions(+), 174 deletions(-)
build/jam/images/definitions/minimum | 4 +
build/jam/images/definitions/regular | 2 +-
build/jam/packages/Haiku | 11 +-
build/jam/packages/HaikuBootstrap | 12 +-
data/launch/system | 14 +-
data/launch/user | 10 +-
data/settings/first_login | 1 +
data/system/boot/PostInstallScript | 13 +-
.../default_deskbar_items.sh | 0
src/apps/deskbar/BarApp.cpp | 2 +-
src/apps/deskbar/BarApp.h | 4 +-
src/bin/Jamfile | 1 +
src/bin/cddb_lookup/Jamfile | 11 ++
.../cddb_lookup/cddb_lookup.cpp} | 169 ++++++++++---------
.../cddb_lookup/cddb_lookup.rdef} | 6 +-
.../cddb_lookup}/cddb_server.cpp | 10 +-
.../cddb_lookup}/cddb_server.h | 0
src/servers/Jamfile | 1 -
src/servers/cddb_daemon/Jamfile | 11 --
src/servers/cddb_daemon/cddb_daemon.h | 41 -----
src/servers/launch/Conditions.cpp | 2 +-
src/servers/launch/LaunchDaemon.cpp | 2 +-
src/servers/launch/Utility.cpp | 16 ++
src/servers/launch/Utility.h | 4 +-
src/tests/servers/launch/Jamfile | 1 +
.../servers/launch/LaunchDaemonTestAddon.cpp | 2 +
src/tests/servers/launch/UtilityTest.cpp | 56 ++++++
src/tests/servers/launch/UtilityTest.h | 24 +++

############################################################################

Commit: cfe6baf62f7ec4a0bc200bd2e6843a000e33de2b
URL: http://cgit.haiku-os.org/haiku/commit/?id=cfe6baf62f7e
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Oct 19 18:06:11 2015 UTC

cddb_daemon: renamed to cddb_lookup, moved to /src/bin.

* It's now a standard command line tool that is launched automatically
via the launch_daemon whenver a volume is mounted.

----------------------------------------------------------------------------

diff --git a/build/jam/images/definitions/regular
b/build/jam/images/definitions/regular
index 0384d6b..dca1b9e 100644
--- a/build/jam/images/definitions/regular
+++ b/build/jam/images/definitions/regular
@@ -4,6 +4,7 @@
include [ FDirName $(HAIKU_BUILD_RULES_DIR) images definitions minimum ] ;

SYSTEM_BIN += [ FFilterByBuildFeatures
+ cddb_lookup
clipboard CortexAddOnHost
FirstBootPrompt fwcontrol@x86
installsound
@@ -91,7 +92,6 @@ rule HaikuImageGetPrivateSystemLibs


SYSTEM_SERVERS += [ FFilterByBuildFeatures
- cddb_daemon
mail_daemon media_addon_server media_server midi_server
nfs4_idmapper_server
print_server print_addon_server
diff --git a/data/launch/system b/data/launch/system
index 194db4c..9c2d5cd 100644
--- a/data/launch/system
+++ b/data/launch/system
@@ -55,12 +55,6 @@ service x-vnd.Haiku-net_server {
legacy
}

-service x-vnd.Haiku-cddb_daemon {
- launch /system/servers/cddb_daemon
- no_safemode
- legacy
-}
-
service x-vnd.Haiku-print_server {
launch /system/servers/print_server
no_safemode
@@ -79,6 +73,12 @@ service x-vnd.Haiku-power_daemon {
legacy
}

+job x-vnd.Haiku-cddb_lookup {
+ launch /system/bin/cddb_lookup
+ no_safemode
+ on volume_mounted
+}
+
job post-install {
launch /bin/sh /system/boot/PostInstallScript
if file_exists /boot/system/settings/fresh_install
diff --git a/src/bin/Jamfile b/src/bin/Jamfile
index 3768ac2..f0fa7ed 100644
--- a/src/bin/Jamfile
+++ b/src/bin/Jamfile
@@ -265,6 +265,7 @@ DoCatalogs filepanel
SubInclude HAIKU_TOP src bin addattr ;
SubInclude HAIKU_TOP src bin bc ;
SubInclude HAIKU_TOP src bin bfs_tools ;
+SubInclude HAIKU_TOP src bin cddb_lookup ;
SubInclude HAIKU_TOP src bin compress ;
SubInclude HAIKU_TOP src bin consoled ;
SubInclude HAIKU_TOP src bin coreutils ;
diff --git a/src/bin/cddb_lookup/Jamfile b/src/bin/cddb_lookup/Jamfile
new file mode 100644
index 0000000..3d622ce
--- /dev/null
+++ b/src/bin/cddb_lookup/Jamfile
@@ -0,0 +1,11 @@
+SubDir HAIKU_TOP src bin cddb_lookup ;
+
+UsePrivateHeaders drivers ;
+
+AddResources cddb_lookup : cddb_lookup.rdef ;
+
+BinCommand cddb_lookup :
+ cddb_lookup.cpp
+ cddb_server.cpp
+ : be bnetapi [ TargetLibsupc++ ]
+ ;
diff --git a/src/servers/cddb_daemon/cddb_daemon.cpp
b/src/bin/cddb_lookup/cddb_lookup.cpp
similarity index 68%
rename from src/servers/cddb_daemon/cddb_daemon.cpp
rename to src/bin/cddb_lookup/cddb_lookup.cpp
index c9ac1d8..b87592a 100644
--- a/src/servers/cddb_daemon/cddb_daemon.cpp
+++ b/src/bin/cddb_lookup/cddb_lookup.cpp
@@ -1,80 +1,80 @@
/*
- * Copyright 2008-2009, Haiku, Inc. All Rights Reserved.
+ * Copyright 2008-2015, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
- * Bruno Albuquerque, bga@xxxxxxxxxxxxx
+ * Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ * Bruno Albuquerque, bga@xxxxxxxxxxxxx
*/

-#include "cddb_daemon.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

+#include <Application.h>
#include <Directory.h>
#include <Entry.h>
#include <fs_info.h>
#include <Message.h>
-#include <NodeMonitor.h>
#include <Volume.h>
#include <VolumeRoster.h>

+#include <scsi_cmds.h>
+
#include "cddb_server.h"


+class CDDBLookup : public BApplication {
+public:
+ CDDBLookup();
+ virtual ~CDDBLookup();
+
+ void LookupAll();
+ status_t Lookup(const dev_t
device);
+
+private:
+ bool _CanLookup(const dev_t
device, uint32* cddbId,
+
scsi_toc_toc* toc) const;
+ QueryResponseData* _SelectResult(BList* response)
const;
+ status_t _WriteCDData(dev_t
device,
+
QueryResponseData* diskData,
+
ReadResponseData* readResponse);
+};
+
+
+extern const char *__progname;
+static const char *kProgramName = __progname;
+
static const char* kCddaFsName = "cdda";
static const int kMaxTocSize = 1024;


-CDDBDaemon::CDDBDaemon()
- : BApplication("application/x-vnd.Haiku-cddb_daemon"),
- fVolumeRoster(new BVolumeRoster)
+CDDBLookup::CDDBLookup()
+ :
+ BApplication("application/x-vnd.Haiku-cddb_lookup")
{
- fVolumeRoster->StartWatching();
-
- BVolume volume;
- printf("Checking currently mounted volumes ...\n");
- while (fVolumeRoster->GetNextVolume(&volume) == B_OK) {
- if (_Lookup(volume.Device()) != B_OK) {
- continue;
- }
- }
- printf("Checking complete. Listening for device mounts.\n");
}


-CDDBDaemon::~CDDBDaemon()
+CDDBLookup::~CDDBLookup()
{
- fVolumeRoster->StopWatching();
- delete fVolumeRoster;
}


void
-CDDBDaemon::MessageReceived(BMessage* message)
+CDDBLookup::LookupAll()
{
- switch(message->what) {
- case B_NODE_MONITOR:
- int32 opcode;
- if (message->FindInt32("opcode", &opcode) == B_OK) {
- if (opcode == B_DEVICE_MOUNTED) {
- dev_t device;
- if (message->FindInt32("new device",
&device) == B_OK) {
- if (_Lookup(device) != B_OK)
- break;
- }
- }
- }
- break;
- default:
- BApplication::MessageReceived(message);
+ BVolumeRoster roster;
+ BVolume volume;
+ while (roster.GetNextVolume(&volume) == B_OK) {
+ Lookup(volume.Device());
}
}


status_t
-CDDBDaemon::_Lookup(const dev_t device)
+CDDBLookup::Lookup(const dev_t device)
{
scsi_toc_toc* toc = (scsi_toc_toc*)malloc(kMaxTocSize);
if (toc == NULL)
@@ -86,7 +86,7 @@ CDDBDaemon::_Lookup(const dev_t device)
printf("Skipping device with id %" B_PRId32 ".\n", device);
return B_BAD_TYPE;
}
-
+
printf("Looking up CD with CDDB Id %08" B_PRIx32 ".\n", cddbId);

CDDBServer cddb_server("freedb.freedb.org:80");
@@ -99,7 +99,7 @@ CDDBDaemon::_Lookup(const dev_t device)
free(toc);
return result;
}
-
+
free(toc);

QueryResponseData* diskData = _SelectResult(&queryResponse);
@@ -112,7 +112,7 @@ CDDBDaemon::_Lookup(const dev_t device)
if ((result = cddb_server.Read(diskData, &readResponse)) != B_OK) {
return result;
}
-
+
if (_WriteCDData(device, diskData, &readResponse) == B_OK) {
printf("CD data saved.\n");
} else {
@@ -124,7 +124,7 @@ CDDBDaemon::_Lookup(const dev_t device)
for (int32 i = 0; i < count; ++i) {
delete (QueryResponseData*)queryResponse.RemoveItem((int32)0);
}
-
+
queryResponse.MakeEmpty();

// Delete itens in the track data BList in the read response data;
@@ -132,15 +132,15 @@ CDDBDaemon::_Lookup(const dev_t device)
for (int32 i = 0; i < count; ++i) {
delete (TrackData*)readResponse.tracks.RemoveItem((int32)0);
}
-
+
readResponse.tracks.MakeEmpty();
-
+
return B_OK;
}


bool
-CDDBDaemon::_CanLookup(const dev_t device, uint32* cddbId,
+CDDBLookup::_CanLookup(const dev_t device, uint32* cddbId,
scsi_toc_toc* toc) const
{
if (cddbId == NULL || toc == NULL)
@@ -151,7 +151,7 @@ CDDBDaemon::_CanLookup(const dev_t device, uint32* cddbId,
fs_stat_dev(device, &info);
if (strncmp(info.fsh_name, kCddaFsName, strlen(kCddaFsName)) != 0)
return false;
-
+
// Does it have the CD:do_lookup attribute and is it true?
BVolume volume(device);
BDirectory directory;
@@ -165,19 +165,19 @@ CDDBDaemon::_CanLookup(const dev_t device, uint32* cddbId,
// Does it have the CD:cddbid attribute?
if (directory.ReadAttr("CD:cddbid", B_UINT32_TYPE, 0, (void *)cddbId,
sizeof(uint32)) < B_OK)
- return false;
+ return false;

// Does it have the CD:toc attribute?
if (directory.ReadAttr("CD:toc", B_RAW_TYPE, 0, (void *)toc,
kMaxTocSize) < B_OK)
return false;
-
+
return true;
}


QueryResponseData*
-CDDBDaemon::_SelectResult(BList* response) const
+CDDBLookup::_SelectResult(BList* response) const
{
// Select a single CD match from the response and return it.
//
@@ -197,7 +197,7 @@ CDDBDaemon::_SelectResult(BList* response) const
if (numItems > 1) {
printf("Returning first entry.\n");
}
-
+
return (QueryResponseData*)response->ItemAt(0L);
}

@@ -206,81 +206,88 @@ CDDBDaemon::_SelectResult(BList* response) const


status_t
-CDDBDaemon::_WriteCDData(dev_t device, QueryResponseData* diskData,
+CDDBLookup::_WriteCDData(dev_t device, QueryResponseData* diskData,
ReadResponseData* readResponse)
{
// Rename volume.
BVolume volume(device);
-
- status_t result;
+
status_t error = B_OK;
-
+
BString name = diskData->artist << " - " << diskData->title;
name.ReplaceSet("/", " ");
-
- if ((result = volume.SetName(name.String())) != B_OK) {
+
+ status_t result = volume.SetName(name.String());
+ if (result != B_OK) {
printf("Can't set volume name.\n");
return result;
}
-
- // Rename tracks and add relevant Audio attributes.
+
+ // Rename tracks and add relevant Audio attributes.
BDirectory cddaRoot;
volume.GetRootDirectory(&cddaRoot);
-
+
BEntry entry;
int index = 0;
while (cddaRoot.GetNextEntry(&entry) == B_OK) {
TrackData* data =
(TrackData*)((readResponse->tracks).ItemAt(index));
-
+
// Update name.
int trackNum = index + 1; // index=0 is actually Track 1
name.SetToFormat("%02d %s.wav", trackNum, data->title.String());
name.ReplaceSet("/", " ");

- if ((result = entry.Rename(name.String())) != B_OK) {
- printf("Failed renaming entry at index %d to
\"%s\".\n", index,
- name.String());
+ result = entry.Rename(name.String());
+ if (result != B_OK) {
+ fprintf(stderr, "%s: Failed renaming entry at index %d
to "
+ "\"%s\".\n", kProgramName, index,
name.String());
error = result;
// User can benefit from continuing through all
tracks.
// Report error later.
}
-
+
// Add relevant attributes. We consider an error here as
non-fatal.
BNode node(&entry);
- node.WriteAttr("Media:Title", B_STRING_TYPE, 0,
(data->title).String(),
- (data->title).Length());
+ node.WriteAttr("Media:Title", B_STRING_TYPE, 0,
data->title.String(),
+ data->title.Length());
node.WriteAttr("Audio:Album", B_STRING_TYPE, 0,
- (readResponse->title).String(),
- (readResponse->title).Length());
+ readResponse->title.String(),
+ readResponse->title.Length());
if (readResponse->genre.Length() != 0) {
node.WriteAttr("Media:Genre", B_STRING_TYPE, 0,
- (readResponse->genre).String(),
- (readResponse->genre).Length());
+ readResponse->genre.String(),
+ readResponse->genre.Length());
}
if (readResponse->year != 0) {
node.WriteAttr("Media:Year", B_INT32_TYPE, 0,
- &(readResponse->year), sizeof(int32));
+ &readResponse->year, sizeof(int32));
}

if (data->artist == "") {
node.WriteAttr("Audio:Artist", B_STRING_TYPE, 0,
- (readResponse->artist).String(),
- (readResponse->artist).Length());
+ readResponse->artist.String(),
+ readResponse->artist.Length());
} else {
node.WriteAttr("Audio:Artist", B_STRING_TYPE, 0,
- (data->artist).String(),
(data->artist).Length());
+ data->artist.String(), data->artist.Length());
}
-
+
index++;
}
-
+
return error;
-}
+}


-int main(void) {
- printf("CDDB Daemon for Haiku v1.0.0 started.\n");
- CDDBDaemon* cddbDaemon = new CDDBDaemon();
- cddbDaemon->Run();
- delete cddbDaemon;
+// #pragma mark -
+
+
+int
+main(void)
+{
+ // TODO: support arguments to specify a device
+ CDDBLookup cddb;
+ cddb.LookupAll();
+
+ return 0;
}
diff --git a/src/servers/cddb_daemon/cddb_daemon.rdef
b/src/bin/cddb_lookup/cddb_lookup.rdef
similarity index 94%
rename from src/servers/cddb_daemon/cddb_daemon.rdef
rename to src/bin/cddb_lookup/cddb_lookup.rdef
index 816f9f0..ca72fef 100644
--- a/src/servers/cddb_daemon/cddb_daemon.rdef
+++ b/src/bin/cddb_lookup/cddb_lookup.rdef
@@ -1,4 +1,4 @@
-resource app_signature "application/x-vnd.Haiku-cddb_daemon";
+resource app_signature "application/x-vnd.Haiku-cddb_lookup";

resource app_flags B_EXCLUSIVE_LAUNCH | B_BACKGROUND_APP;

@@ -10,8 +10,8 @@ resource app_version {
variety = B_APPV_FINAL,
internal = 3,

- short_info = "Haiku CDDB Daemon",
- long_info = "Haiku CDDB Daemon ©2009 Haiku"
+ short_info = "Haiku CDDB Lookup",
+ long_info = "Haiku CDDB Lookup ©2009-2015 Haiku"
};

#ifdef HAIKU_TARGET_PLATFORM_HAIKU
diff --git a/src/servers/cddb_daemon/cddb_server.cpp
b/src/bin/cddb_lookup/cddb_server.cpp
similarity index 97%
rename from src/servers/cddb_daemon/cddb_server.cpp
rename to src/bin/cddb_lookup/cddb_server.cpp
index fef57bb..df69d46 100644
--- a/src/servers/cddb_daemon/cddb_server.cpp
+++ b/src/bin/cddb_lookup/cddb_server.cpp
@@ -1,11 +1,12 @@
/*
- * Copyright 2008-2009, Haiku, Inc. All Rights Reserved.
+ * Copyright 2008-2015, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Bruno Albuquerque, bga@xxxxxxxxxxxxx
*/

+
#include "cddb_server.h"

#include <errno.h>
@@ -21,7 +22,8 @@ static const uint32 kFramesPerSecond = 75;
static const uint32 kFramesPerMinute = kFramesPerSecond * 60;


-CDDBServer::CDDBServer(const BString& cddbServer):
+CDDBServer::CDDBServer(const BString& cddbServer)
+ :
fInitialized(false),
fConnected(false)
{
@@ -92,7 +94,7 @@ CDDBServer::Query(uint32 cddbId, const scsi_toc_toc* toc,
BList* queryResponse)
output.MoveInto(statusCode, 0, 3);
if (statusCode == "210" || statusCode == "211") {
// TODO(bga): We can get around with returning the
first result
- // in case of multiple matches, but we most definitely
needs a
+ // in case of multiple matches, but we most definitely
need a
// better handling of inexact matches.
if (statusCode == "211")
printf("Warning : Inexact match found.\n");
@@ -367,7 +369,7 @@ CDDBServer::_SendCddbCommand(const BString& command,
BString* output)
// Assemble full command string.
BString fullCommand;
fullCommand << command << "&hello=" << fLocalUserName << " " <<
- fLocalHostName << " cddb_daemon 1.0&proto=6";
+ fLocalHostName << " cddb_lookup 1.0&proto=6";

// Replace spaces by + signs.
fullCommand.ReplaceAll(" ", "+");
diff --git a/src/servers/cddb_daemon/cddb_server.h
b/src/bin/cddb_lookup/cddb_server.h
similarity index 100%
rename from src/servers/cddb_daemon/cddb_server.h
rename to src/bin/cddb_lookup/cddb_server.h
diff --git a/src/servers/Jamfile b/src/servers/Jamfile
index 5a89c6d..327d0c2 100644
--- a/src/servers/Jamfile
+++ b/src/servers/Jamfile
@@ -2,7 +2,6 @@ SubDir HAIKU_TOP src servers ;

SubInclude HAIKU_TOP src servers app ;
SubInclude HAIKU_TOP src servers bluetooth ;
-SubInclude HAIKU_TOP src servers cddb_daemon ;
SubInclude HAIKU_TOP src servers debug ;
SubInclude HAIKU_TOP src servers index ;
SubInclude HAIKU_TOP src servers input ;
diff --git a/src/servers/cddb_daemon/Jamfile b/src/servers/cddb_daemon/Jamfile
deleted file mode 100644
index 61ed08d..0000000
--- a/src/servers/cddb_daemon/Jamfile
+++ /dev/null
@@ -1,11 +0,0 @@
-SubDir HAIKU_TOP src servers cddb_daemon ;
-
-UsePrivateHeaders drivers ;
-
-AddResources cddb_daemon : cddb_daemon.rdef ;
-
-Server cddb_daemon :
- cddb_daemon.cpp
- cddb_server.cpp
- : be bnetapi [ TargetLibsupc++ ]
- ;
diff --git a/src/servers/cddb_daemon/cddb_daemon.h
b/src/servers/cddb_daemon/cddb_daemon.h
deleted file mode 100644
index 8718c7a..0000000
--- a/src/servers/cddb_daemon/cddb_daemon.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2008-2009, Haiku, Inc. All Rights Reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- * Bruno Albuquerque, bga@xxxxxxxxxxxxx
- */
-
-#ifndef _CDDB_DAEMON_H
-#define _CDDB_DAEMON_H
-
-#include <Application.h>
-
-#include <scsi_cmds.h>
-
-struct ReadResponseData;
-struct QueryResponseData;
-
-class BList;
-class BMessage;
-class BVolumeRoster;
-
-class CDDBDaemon : public BApplication {
-public:
- CDDBDaemon();
- virtual ~CDDBDaemon();
-
- virtual void MessageReceived(BMessage* message);
-
-private:
- status_t _Lookup(const dev_t device);
- bool _CanLookup(const dev_t device, uint32*
cddbId,
- scsi_toc_toc* toc)
const;
- QueryResponseData* _SelectResult(BList* response) const;
- status_t _WriteCDData(dev_t device,
QueryResponseData* diskData,
- ReadResponseData*
readResponse);
-
- BVolumeRoster* fVolumeRoster;
-};
-
-#endif // _CDDB_DAEMON_H

############################################################################

Commit: 4e8fc45146c05093d522aebb9a9c752122d9d056
URL: http://cgit.haiku-os.org/haiku/commit/?id=4e8fc45146c0
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Oct 19 18:14:23 2015 UTC

Deskbar: converted to BServer.

----------------------------------------------------------------------------

diff --git a/data/launch/user b/data/launch/user
index be034a9..7f4c538 100644
--- a/data/launch/user
+++ b/data/launch/user
@@ -11,7 +11,6 @@ target desktop {

service x-vnd.Be-TSKB {
launch /system/Deskbar
- legacy
on {
initial_volumes_mounted
}
diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index e5dc306..ed1c6f2 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -94,7 +94,7 @@ main()

TBarApp::TBarApp()
:
- BApplication(kDeskbarSignature),
+ BServer(kDeskbarSignature, true, NULL),
fSettingsFile(NULL),
fClockSettingsFile(NULL),
fPreferencesWindow(NULL)
diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
index 62f16b4..5a14657 100644
--- a/src/apps/deskbar/BarApp.h
+++ b/src/apps/deskbar/BarApp.h
@@ -36,7 +36,7 @@ All rights reserved.
#define BAR_APP_H


-#include <Application.h>
+#include <Server.h>

#include "BarSettings.h"

@@ -105,7 +105,7 @@ public:
BBitmap*
iconCache[kIconCacheCount];
};

-class TBarApp : public BApplication {
+class TBarApp : public BServer {
public:

TBarApp();
virtual ~TBarApp();

############################################################################

Commit: d9bb9513c5e9b36cd4761fffb6f59e141c8aa692
URL: http://cgit.haiku-os.org/haiku/commit/?id=d9bb9513c5e9
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Oct 19 18:53:15 2015 UTC

launch_daemon: "file_exists" now resolves $HOME, and '~'.

----------------------------------------------------------------------------

diff --git a/data/launch/user b/data/launch/user
index 7f4c538..e771d76 100644
--- a/data/launch/user
+++ b/data/launch/user
@@ -17,7 +17,7 @@ target desktop {
}

job user-bootscript {
- launch /bin/sh /boot/home/config/settings/boot/UserBootscript
+ launch /bin/sh ~/config/settings/boot/UserBootscript
}

job create-installer-link {
@@ -26,7 +26,7 @@ target desktop {
read_only
file_exists /boot/system/apps/Installer
}
- launch /bin/ln -sf /boot/system/apps/Installer
/boot/home/Desktop/Installer
+ launch /bin/ln -sf /boot/system/apps/Installer
~/Desktop/Installer
}
}

diff --git a/src/servers/launch/Conditions.cpp
b/src/servers/launch/Conditions.cpp
index c825fdf..0231112 100644
--- a/src/servers/launch/Conditions.cpp
+++ b/src/servers/launch/Conditions.cpp
@@ -413,7 +413,7 @@ FileExistsCondition::FileExistsCondition(const BMessage&
args)
{
for (int32 index = 0;
const char* path = args.GetString("args", index, NULL);
index++) {
- fPaths.Add(path);
+ fPaths.Add(Utility::TranslatePath(path));
}
}

diff --git a/src/servers/launch/LaunchDaemon.cpp
b/src/servers/launch/LaunchDaemon.cpp
index cbcebeb..69e9258 100644
--- a/src/servers/launch/LaunchDaemon.cpp
+++ b/src/servers/launch/LaunchDaemon.cpp
@@ -975,7 +975,7 @@ LaunchDaemon::_AddJob(Target* target, bool service,
BMessage& message)
const char* argument;
for (int32 index = 0; message.FindString("launch", index,
&argument)
== B_OK; index++) {
- job->AddArgument(argument);
+ job->AddArgument(Utility::TranslatePath(argument));
}
}

diff --git a/src/servers/launch/Utility.cpp b/src/servers/launch/Utility.cpp
index 17f139f..b936ef3 100644
--- a/src/servers/launch/Utility.cpp
+++ b/src/servers/launch/Utility.cpp
@@ -99,4 +99,20 @@ EjectMedia(const char* path)
}


+BString
+TranslatePath(const char* originalPath)
+{
+ BString path = originalPath;
+
+ // TODO: get actual home directory!
+ const char* home = "/boot/home";
+ path.ReplaceAll("$HOME", home);
+ path.ReplaceAll("${HOME}", home);
+ if (path.StartsWith("~/"))
+ path.ReplaceFirst("~", home);
+
+ return path;
+}
+
+
} // namespace Utility
diff --git a/src/servers/launch/Utility.h b/src/servers/launch/Utility.h
index b5daf6d..385dd28 100644
--- a/src/servers/launch/Utility.h
+++ b/src/servers/launch/Utility.h
@@ -6,7 +6,7 @@
#define UTILITY_H


-#include <SupportDefs.h>
+#include <String.h>


namespace Utility {
@@ -15,6 +15,8 @@ namespace Utility {

status_t BlockMedia(const char* path, bool block);
status_t EjectMedia(const char* path);
+
+ BString TranslatePath(const char* path);
}


diff --git a/src/tests/servers/launch/Jamfile b/src/tests/servers/launch/Jamfile
index f530bf6..1ce341c 100644
--- a/src/tests/servers/launch/Jamfile
+++ b/src/tests/servers/launch/Jamfile
@@ -11,6 +11,7 @@ UnitTestLib liblaunch_daemontest.so :

SettingsParserTest.cpp
ConditionsTest.cpp
+ UtilityTest.cpp

# from the launch_daemon
SettingsParser.cpp
diff --git a/src/tests/servers/launch/LaunchDaemonTestAddon.cpp
b/src/tests/servers/launch/LaunchDaemonTestAddon.cpp
index 497d5f6..bb20688 100644
--- a/src/tests/servers/launch/LaunchDaemonTestAddon.cpp
+++ b/src/tests/servers/launch/LaunchDaemonTestAddon.cpp
@@ -9,6 +9,7 @@

#include "ConditionsTest.h"
#include "SettingsParserTest.h"
+#include "UtilityTest.h"


BTestSuite*
@@ -18,6 +19,7 @@ getTestSuite()

SettingsParserTest::AddTests(*suite);
ConditionsTest::AddTests(*suite);
+ UtilityTest::AddTests(*suite);

return suite;
}
diff --git a/src/tests/servers/launch/UtilityTest.cpp
b/src/tests/servers/launch/UtilityTest.cpp
new file mode 100644
index 0000000..70841c9
--- /dev/null
+++ b/src/tests/servers/launch/UtilityTest.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2015, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "UtilityTest.h"
+
+#include <stdlib.h>
+
+#include <cppunit/TestCaller.h>
+#include <cppunit/TestSuite.h>
+
+#include "Utility.h"
+
+
+UtilityTest::UtilityTest()
+{
+}
+
+
+UtilityTest::~UtilityTest()
+{
+}
+
+
+void
+UtilityTest::TestTranslatePath()
+{
+ CPPUNIT_ASSERT_EQUAL(BString("/boot/home/test"),
+ Utility::TranslatePath("$HOME/test"));
+ CPPUNIT_ASSERT_EQUAL(BString("/boot/home/test"),
+ Utility::TranslatePath("${HOME}/test"));
+ CPPUNIT_ASSERT_EQUAL(BString("--/boot/home--"),
+ Utility::TranslatePath("--${HOME}--"));
+ CPPUNIT_ASSERT_EQUAL(BString("$(HOME)/test"),
+ Utility::TranslatePath("$(HOME)/test"));
+ CPPUNIT_ASSERT_EQUAL(BString("/boot/home/test"),
+ Utility::TranslatePath("~/test"));
+ CPPUNIT_ASSERT_EQUAL(BString("~baron/test"),
+ Utility::TranslatePath("~baron/test"));
+ CPPUNIT_ASSERT_EQUAL(BString("/~/test"),
+ Utility::TranslatePath("/~/test"));
+}
+
+
+/*static*/ void
+UtilityTest::AddTests(BTestSuite& parent)
+{
+ CppUnit::TestSuite& suite = *new CppUnit::TestSuite("UtilityTest");
+
+ suite.addTest(new CppUnit::TestCaller<UtilityTest>(
+ "UtilityTest::TestTranslatePath", &UtilityTest::TestEmpty));
+
+ parent.addTest("UtilityTest", &suite);
+}
diff --git a/src/tests/servers/launch/UtilityTest.h
b/src/tests/servers/launch/UtilityTest.h
new file mode 100644
index 0000000..ab80649
--- /dev/null
+++ b/src/tests/servers/launch/UtilityTest.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2015, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef UTILITY_TEST_H
+#define UTILITY_TEST_H
+
+
+#include <TestCase.h>
+#include <TestSuite.h>
+
+
+class UtilityTest : public CppUnit::TestCase {
+public:
+ UtilityTest();
+ virtual ~UtilityTest();
+
+ void TestTranslatePath();
+
+ static void AddTests(BTestSuite& suite);
+};
+
+
+#endif // UTILITY_TEST_H

############################################################################

Revision: hrev49707
Commit: d2eca26b735090011c1892465e324729a11c19d8
URL: http://cgit.haiku-os.org/haiku/commit/?id=d2eca26b7350
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Oct 19 19:09:55 2015 UTC

Ticket: https://dev.haiku-os.org/ticket/12275

Moved per user post install actions to first-login script.

* The same mechanism (and the same PostInstallScript) is used for this.
* If a file first_login exists in ~/config/settings/boot, the first-login
scripts are launched, and the file removed.
* This fixes adding the deskbar tray icons even when there is no Deskbar
running yet (for example on first boot when the FirstBootPrompt
starts), or, IOW bug #12275.

----------------------------------------------------------------------------

diff --git a/build/jam/images/definitions/minimum
b/build/jam/images/definitions/minimum
index c593563..6321369 100644
--- a/build/jam/images/definitions/minimum
+++ b/build/jam/images/definitions/minimum
@@ -254,6 +254,10 @@ local userBootScripts = UserBootscript
UserSetupEnvironment.sample ;
SEARCH on $(userBootScripts) = [ FDirName $(HAIKU_TOP) data config boot ] ;
AddFilesToHaikuImage home config settings boot : $(userBootScripts) ;

+SEARCH on <user-first-login>first_login
+ = [ FDirName $(HAIKU_TOP) data settings ] ;
+AddFilesToHaikuImage home config settings : <user-first-login>first_login ;
+
local etcDir = [ FDirName $(HAIKU_TOP) data etc ] ;
local etcFiles = inputrc profile ;
etcFiles = $(etcFiles:G=etc) ;
diff --git a/build/jam/packages/Haiku b/build/jam/packages/Haiku
index 13d9ddd..13aef95 100644
--- a/build/jam/packages/Haiku
+++ b/build/jam/packages/Haiku
@@ -137,14 +137,19 @@ local userLaunchScripts = <data!launch>user ;
SEARCH on $(userLaunchScripts) = [ FDirName $(HAIKU_TOP) data launch ] ;
AddFilesToPackage data user_launch : $(userLaunchScripts) ;

-# post install scripts
-local postInstallFiles = add_catalog_entry_attributes.sh
- default_deskbar_items.sh ;
+# post install + first login scripts
+local postInstallFiles = add_catalog_entry_attributes.sh ;
postInstallFiles = $(postInstallFiles:G=post-install) ;
SEARCH on $(postInstallFiles)
= [ FDirName $(HAIKU_TOP) data system boot post_install ] ;
AddFilesToPackage boot post-install : $(postInstallFiles) ;

+local firstLoginFiles = default_deskbar_items.sh ;
+firstLoginFiles = $(firstLoginFiles:G=first-login) ;
+SEARCH on $(firstLoginFiles)
+ = [ FDirName $(HAIKU_TOP) data system boot first_login ] ;
+AddFilesToPackage boot first-login : $(firstLoginFiles) ;
+
# artwork and sounds
local logoArtwork =
$(HAIKU_INCLUDE_TRADEMARKS)"HAIKU logo - white on blue - big.png"
diff --git a/build/jam/packages/HaikuBootstrap
b/build/jam/packages/HaikuBootstrap
index 49aa91f..765d89c 100644
--- a/build/jam/packages/HaikuBootstrap
+++ b/build/jam/packages/HaikuBootstrap
@@ -134,12 +134,12 @@ local userLaunchScripts = <data!launch>user ;
SEARCH on $(userLaunchScripts) = [ FDirName $(HAIKU_TOP) data launch ] ;
AddFilesToPackage data user_launch : $(userLaunchScripts) ;

-# post install scripts
-local postInstallFiles = default_deskbar_items.sh ;
-postInstallFiles = $(postInstallFiles:G=post-install) ;
-SEARCH on $(postInstallFiles)
- = [ FDirName $(HAIKU_TOP) data system boot post_install ] ;
-AddFilesToPackage boot post-install : $(postInstallFiles) ;
+# first login scripts
+local firstLoginFiles = default_deskbar_items.sh ;
+firstLoginFiles = $(firstLoginFiles:G=first-login) ;
+SEARCH on $(firstLoginFiles)
+ = [ FDirName $(HAIKU_TOP) data system boot first_login ] ;
+AddFilesToPackage boot first_login : $(firstLoginFiles) ;

local fortuneFiles = [ Glob $(HAIKU_TOP)/data/system/data/fortunes
: [a-zA-Z0-9]* ] ;
diff --git a/data/launch/system b/data/launch/system
index 9c2d5cd..9d83497 100644
--- a/data/launch/system
+++ b/data/launch/system
@@ -80,7 +80,7 @@ job x-vnd.Haiku-cddb_lookup {
}

job post-install {
- launch /bin/sh /system/boot/PostInstallScript
+ launch /bin/sh /system/boot/PostInstallScript "post install"
/boot/system/settings/fresh_install /boot/system/boot/post-install
if file_exists /boot/system/settings/fresh_install
}

diff --git a/data/launch/user b/data/launch/user
index e771d76..023fed3 100644
--- a/data/launch/user
+++ b/data/launch/user
@@ -20,6 +20,11 @@ target desktop {
launch /bin/sh ~/config/settings/boot/UserBootscript
}

+ job first-login {
+ launch /bin/sh /system/boot/PostInstallScript "first login"
~/config/settings/first_login /boot/system/boot/first-login
+ if file_exists ~/config/settings/first_login
+ }
+
job create-installer-link {
# When run from a read-only medium a.k.a. live desktop
if {
diff --git a/data/settings/first_login b/data/settings/first_login
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/data/settings/first_login
@@ -0,0 +1 @@
+1
diff --git a/data/system/boot/PostInstallScript
b/data/system/boot/PostInstallScript
index 9b22092..6fa36e5 100644
--- a/data/system/boot/PostInstallScript
+++ b/data/system/boot/PostInstallScript
@@ -2,17 +2,16 @@

# Check for fresh install and run post install scripts.

-freshInstallIndicator=/boot/system/settings/fresh_install
-postInstallDir=boot/post-install
-if [ -e $freshInstallIndicator ]; then
- # wait a moment for things to calm down a bit
- sleep 3
+title=$1
+freshInstallIndicator=$2
+postInstallDir=$3

+if [ -e $freshInstallIndicator ]; then
# execute scripts
- for f in /boot/system/$postInstallDir/*.sh
+ for f in $postInstallDir/*.sh
do
if [ -f $f ]; then
- echo "Running post install script $f ..." > /dev/dprintf
+ echo "Running $title script $f ..." > /dev/dprintf
$f
fi
done
diff --git a/data/system/boot/post_install/default_deskbar_items.sh
b/data/system/boot/first_login/default_deskbar_items.sh
similarity index 100%
rename from data/system/boot/post_install/default_deskbar_items.sh
rename to data/system/boot/first_login/default_deskbar_items.sh


Other related posts:

  • » [haiku-commits] haiku: hrev49707 - src/servers/cddb_daemon src/bin/cddb_lookup src/tests/servers/launch data - axeld