[haiku-commits] haiku: hrev47431 - src/bin src/kits/app headers/os/app

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 26 Jun 2014 01:34:49 +0200 (CEST)

hrev47431 adds 4 changesets to branch 'master'
old head: 9760ac0d19a5098b4f1fb5ef67a219fbad3289ff
new head: 78d6fb3c8e22416c6c05cbf63aebb9a84a5d3a83
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=78d6fb3+%5E9760ac0

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

732c579: Roster: style fixes.
  
  * Check if == NULL or == 0 explicitily
  * Use NULL instead of 0 as default value for pointers in header.
  * other little stuff, new lines, comments

807a7aa: Roster: print when sending B_READY_TO_RUN

ade1697: open: style fixes

78d6fb3: open: get kTrackerSignature variable from tracker_private.h
  
  Update copyright.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

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

3 files changed, 63 insertions(+), 52 deletions(-)
headers/os/app/Roster.h | 16 +++++------
src/bin/open.cpp        | 69 +++++++++++++++++++++++++--------------------
src/kits/app/Roster.cpp | 30 +++++++++++---------

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

Commit:      732c579702e8601d9838249652cc8b1d425ce0c5
URL:         http://cgit.haiku-os.org/haiku/commit/?id=732c579
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Jun 25 23:31:24 2014 UTC

Roster: style fixes.

* Check if == NULL or == 0 explicitily
* Use NULL instead of 0 as default value for pointers in header.
* other little stuff, new lines, comments

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

diff --git a/headers/os/app/Roster.h b/headers/os/app/Roster.h
index db85974..f26ad08 100644
--- a/headers/os/app/Roster.h
+++ b/headers/os/app/Roster.h
@@ -100,21 +100,21 @@ public:
 
        // launch app
                        status_t                        Launch(const char* 
mimeType,
-                                                                       
BMessage* initialMessage = 0,
-                                                                       
team_id* appTeam = 0) const;
+                                                                       
BMessage* initialMessage = NULL,
+                                                                       
team_id* appTeam = NULL) const;
                        status_t                        Launch(const char* 
mimeType, BList* messageList,
-                                                                       
team_id* appTeam = 0) const;
+                                                                       
team_id* appTeam = NULL) const;
                        status_t                        Launch(const char* 
mimeType, int argc,
-                                                                       char* 
*args, team_id* appTeam = 0) const;
+                                                                       char* 
*args, team_id* appTeam = NULL) const;
                        status_t                        Launch(const entry_ref* 
ref,
-                                                                       const 
BMessage* initialMessage = 0,
-                                                                       
team_id* appTeam = 0) const;
+                                                                       const 
BMessage* initialMessage = NULL,
+                                                                       
team_id* appTeam = NULL) const;
                        status_t                        Launch(const entry_ref* 
ref,
                                                                        const 
BList* messageList,
-                                                                       
team_id* appTeam = 0) const;
+                                                                       
team_id* appTeam = NULL) const;
                        status_t                        Launch(const entry_ref* 
ref, int argc,
                                                                        const 
char* const* args,
-                                                                       
team_id* appTeam = 0) const;
+                                                                       
team_id* appTeam = NULL) const;
 
        // recent documents, folders, apps
                        void                            
GetRecentDocuments(BMessage* refList,
diff --git a/src/kits/app/Roster.cpp b/src/kits/app/Roster.cpp
index cf181f1..b4e91a3 100644
--- a/src/kits/app/Roster.cpp
+++ b/src/kits/app/Roster.cpp
@@ -56,11 +56,12 @@ using namespace BPrivate;
 //#define DBG(x) x
 #define DBG(x)
 #ifdef DEBUG_PRINTF
-       #define OUT DEBUG_PRINTF
+#      define OUT DEBUG_PRINTF
 #else
-       #define OUT     printf
+#      define OUT printf
 #endif
 
+
 enum {
        NOT_IMPLEMENTED = B_ERROR,
 };
@@ -946,7 +947,7 @@ BRoster::Launch(const char* mimeType, BMessage* 
initialMessage,
                return B_BAD_VALUE;
 
        BList messageList;
-       if (initialMessage)
+       if (initialMessage != NULL)
                messageList.AddItem(initialMessage);
 
        return _LaunchApp(mimeType, NULL, &messageList, 0, NULL, appTeam);
@@ -987,7 +988,7 @@ BRoster::Launch(const entry_ref* ref, const BMessage* 
initialMessage,
                return B_BAD_VALUE;
 
        BList messageList;
-       if (initialMessage)
+       if (initialMessage != NULL)
                messageList.AddItem(const_cast<BMessage*>(initialMessage));
 
        return _LaunchApp(NULL, ref, &messageList, 0, NULL, appTeam);
@@ -1977,8 +1978,8 @@ BRoster::_LaunchApp(const char* mimeType, const 
entry_ref* ref,
                // If the target app is B_ARGV_ONLY, only if it is newly 
launched
                // messages are sent to it (namely B_ARGV_RECEIVED and 
B_READY_TO_RUN).
                // An already running B_ARGV_ONLY app won't get any messages.
-               bool argvOnly = (appFlags & B_ARGV_ONLY)
-                       || (alreadyRunning && (otherAppFlags & B_ARGV_ONLY));
+               bool argvOnly = (appFlags & B_ARGV_ONLY) != 0
+                       || (alreadyRunning && (otherAppFlags & B_ARGV_ONLY) != 
0);
                const BList* _messageList = (argvOnly ? NULL : messageList);
                // don't send ref, if it refers to the app or is included in the
                // argument vector
@@ -2549,6 +2550,7 @@ BRoster::_SendToRunning(team_id team, int argc, const 
char* const* args,
        bool alreadyRunning) const
 {
        status_t error = B_OK;
+
        // Construct a messenger to the app: We can't use the public 
constructor,
        // since the target application may be B_ARGV_ONLY.
        app_info info;
@@ -2559,16 +2561,16 @@ BRoster::_SendToRunning(team_id team, int argc, const 
char* const* args,
                        B_PREFERRED_TOKEN);
 
                // send messages from the list
-               if (messageList) {
+               if (messageList != NULL) {
                        for (int32 i = 0;
-                                BMessage* message = 
(BMessage*)messageList->ItemAt(i);
-                                i++) {
+                                       BMessage* message = 
(BMessage*)messageList->ItemAt(i);
+                                       i++) {
                                messenger.SendMessage(message);
                        }
                }
 
-               // send B_ARGV_RECEIVED or B_REFS_RECEIVED or B_SILENT_RELAUNCH 
(if
-               // already running)
+               // send B_ARGV_RECEIVED or B_REFS_RECEIVED or B_SILENT_RELAUNCH
+               // (if already running)
                if (args != NULL && argc > 1) {
                        BMessage message(B_ARGV_RECEIVED);
                        message.AddInt32("argc", argc);

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

Commit:      807a7aa09a7259302f46c99e30962d5c38660d94
URL:         http://cgit.haiku-os.org/haiku/commit/?id=807a7aa
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Jun 25 23:32:27 2014 UTC

Roster: print when sending B_READY_TO_RUN

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

diff --git a/src/kits/app/Roster.cpp b/src/kits/app/Roster.cpp
index b4e91a3..281c3d1 100644
--- a/src/kits/app/Roster.cpp
+++ b/src/kits/app/Roster.cpp
@@ -2591,9 +2591,11 @@ BRoster::_SendToRunning(team_id team, int argc, const 
char* const* args,
                } else if (alreadyRunning && (!messageList || 
messageList->IsEmpty()))
                        messenger.SendMessage(B_SILENT_RELAUNCH);
 
-               // send B_READY_TO_RUN
-               if (!alreadyRunning)
+               if (!alreadyRunning) {
+                       // send B_READY_TO_RUN
+                       DBG(OUT("_SendToRunning : B_READY_TO_RUN\n"));
                        messenger.SendMessage(B_READY_TO_RUN);
+               }
        }
 
        return error;

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

Commit:      ade169709bb93051e27d13e0accf14d1f00a8b40
URL:         http://cgit.haiku-os.org/haiku/commit/?id=ade1697
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Jun 25 23:33:18 2014 UTC

open: style fixes

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

diff --git a/src/bin/open.cpp b/src/bin/open.cpp
index 5479267..1dcde8f 100644
--- a/src/bin/open.cpp
+++ b/src/bin/open.cpp
@@ -18,7 +18,6 @@
 #include <Mime.h>
 #include <Roster.h>
 #include <String.h>
-
 #include <Url.h>
 
 
@@ -26,14 +25,14 @@ const char *kTrackerSignature = "application/x-vnd.Be-TRAK";
 
 
 status_t
-open_file(const char* openWith, BEntry &entry, int32 line = -1, int32 col = -1)
+open_file(const char* openWith, BEntry& entry, int32 line = -1, int32 col = -1)
 {
        entry_ref ref;
-       status_t status = entry.GetRef(&ref);
-       if (status < B_OK)
-               return status;
+       status_t result = entry.GetRef(&ref);
+       if (result != B_OK)
+               return result;
 
-       BMessenger target(openWith ? openWith : kTrackerSignature);
+       BMessenger target(openWith != NULL ? openWith : kTrackerSignature);
        if (!target.IsValid())
                return be_roster->Launch(&ref);
 
@@ -41,6 +40,7 @@ open_file(const char* openWith, BEntry &entry, int32 line = 
-1, int32 col = -1)
        message.AddRef("refs", &ref);
        if (line > -1)
                message.AddInt32("be:line", line);
+
        if (col > -1)
                message.AddInt32("be:column", col);
 
@@ -50,12 +50,12 @@ open_file(const char* openWith, BEntry &entry, int32 line = 
-1, int32 col = -1)
 
 
 int
-main(int argc, char **argv)
+main(int argc, char** argv)
 {
-       int exitcode = EXIT_SUCCESS;
-       const char *openWith = NULL;
+       int exitCode = EXIT_SUCCESS;
+       const char* openWith = NULL;
 
-       char *progName = argv[0];
+       char* progName = argv[0];
        if (strrchr(progName, '/'))
                progName = strrchr(progName, '/') + 1;
 
@@ -65,12 +65,12 @@ main(int argc, char **argv)
        }
 
        while (*++argv) {
-               status_t status = B_OK;
+               status_t result = B_OK;
                argc--;
 
                BEntry entry(*argv);
-               if ((status = entry.InitCheck()) == B_OK && entry.Exists()) {
-                       status = open_file(openWith, entry);
+               if ((result = entry.InitCheck()) == B_OK && entry.Exists()) {
+                       result = open_file(openWith, entry);
                } else if (!strncasecmp("application/", *argv, 12)) {
                        // maybe it's an application-mimetype?
 
@@ -84,9 +84,9 @@ main(int argc, char **argv)
                                be_roster->GetAppList(*argv, &teams);
 
                        if (teams.IsEmpty())
-                               status = be_roster->Launch(*argv);
+                               result = be_roster->Launch(*argv);
                        else
-                               status = B_OK;
+                               result = B_OK;
                } else if (strchr(*argv, ':')) {
                        // try to open it as an URI
                        BPrivate::Support::BUrl url(*argv);
@@ -95,7 +95,7 @@ main(int argc, char **argv)
 
                        // maybe it's "file:line" or "file:line:col"
                        int line = 0, col = 0, i;
-                       status = B_ENTRY_NOT_FOUND;
+                       result = B_ENTRY_NOT_FOUND;
                        // remove gcc error's last :
                        BString arg(*argv);
                        if (arg[arg.Length() - 1] == ':')
@@ -106,10 +106,10 @@ main(int argc, char **argv)
                                line = atoi(arg.String() + i + 1);
                                arg.Truncate(i);
 
-                               status = entry.SetTo(arg.String());
-                               if (status == B_OK && entry.Exists()) {
-                                       status = open_file(openWith, entry, 
line);
-                                       if (status == B_OK)
+                               result = entry.SetTo(arg.String());
+                               if (result == B_OK && entry.Exists()) {
+                                       result = open_file(openWith, entry, 
line);
+                                       if (result == B_OK)
                                                continue;
                                }
 
@@ -119,20 +119,20 @@ main(int argc, char **argv)
                                line = atoi(arg.String() + i + 1);
                                arg.Truncate(i);
 
-                               status = entry.SetTo(arg.String());
-                               if (status == B_OK && entry.Exists())
-                                       status = open_file(openWith, entry, 
line, col);
+                               result = entry.SetTo(arg.String());
+                               if (result == B_OK && entry.Exists())
+                                       result = open_file(openWith, entry, 
line, col);
                        }
                } else
-                       status = B_ENTRY_NOT_FOUND;
+                       result = B_ENTRY_NOT_FOUND;
 
-               if (status != B_OK && status != B_ALREADY_RUNNING) {
+               if (result != B_OK && result != B_ALREADY_RUNNING) {
                        fprintf(stderr, "%s: \"%s\": %s\n", progName, *argv,
-                               strerror(status));
+                               strerror(result));
                        // make sure the shell knows this
-                       exitcode = EXIT_FAILURE;
+                       exitCode = EXIT_FAILURE;
                }
        }
 
-       return exitcode;
+       return exitCode;
 }

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

Revision:    hrev47431
Commit:      78d6fb3c8e22416c6c05cbf63aebb9a84a5d3a83
URL:         http://cgit.haiku-os.org/haiku/commit/?id=78d6fb3
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Jun 25 23:34:23 2014 UTC

open: get kTrackerSignature variable from tracker_private.h

Update copyright.

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

diff --git a/src/bin/open.cpp b/src/bin/open.cpp
index 1dcde8f..648573c 100644
--- a/src/bin/open.cpp
+++ b/src/bin/open.cpp
@@ -2,7 +2,15 @@
  * Copyright 2003-2007, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
  * Copyright 2005-2007, François Revol, revol@xxxxxxx.
  * Copyright 2009, Jonas Sundström, jonas@xxxxxxxxxxx.
- * All rights reserved. Distributed under the terms of the MIT License.
+ * Copyright 2014 Haiku, Inc. All rights reserved.
+ *
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ *             François Revol, revol@xxxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
+ *             Jonas Sundström, jonas@xxxxxxxxxxx
  */
 
 /*! Launches an application/document from the shell */
@@ -20,8 +28,7 @@
 #include <String.h>
 #include <Url.h>
 
-
-const char *kTrackerSignature = "application/x-vnd.Be-TRAK";
+#include <tracker_private.h>
 
 
 status_t


Other related posts:

  • » [haiku-commits] haiku: hrev47431 - src/bin src/kits/app headers/os/app - jscipione