From 9e1f887507fd97d0b6939b1396a91c976ab7def5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Sat, 26 Jul 2014 19:45:13 +0200
Subject: Fix paths for writable directories (logs, downloads, shared)

BeShare had the bad habit of putting everything inside
it's own folder...

Now we should have:
~/config/var/log/BeShare/
~/BeShare downloads/
~/BeShare shared/

diff --git a/source/ChatWindow.cpp b/source/ChatWindow.cpp
index 2ee7eef..7b789b0 100644
--- a/source/ChatWindow.cpp
+++ b/source/ChatWindow.cpp
@@ -7,6 +7,7 @@
 #include <Beep.h>
 
 #include <Application.h>
+#include <FindDirectory.h>
 #include <Roster.h>
 #include <MessageFilter.h>
 #include <StringView.h>
@@ -1166,22 +1167,32 @@ ChatWindow::AddBorderView(BView * v)
 status_t
 ChatWindow::GetAppSubdir(const char * subDirName, BDirectory & subDir, bool createIfNecessary) const
 {
-	app_info appInfo;
-	be_app->GetAppInfo(&appInfo);
-	BEntry appEntry(&appInfo.ref);
-	appEntry.GetParent(&appEntry);  // get the directory it's in
-	BPath path(&appEntry);
-	BPath subPath(&appEntry);
-	subPath.Append(subDirName);
+	directory_which which = B_USER_DIRECTORY;
+	if (!strcmp(subDirName, "logs"))
+		which = B_USER_LOG_DIRECTORY;
+	BPath path;
+	status_t err;
+
+	err = find_directory(which, &path, true);
+	if (err != B_OK)
+		return err;
+
+	BDirectory baseDir(path.Path());
+	err = baseDir.InitCheck();
+	if (err != B_OK)
+		return err;
+
+	BString leaf("BeShare");
+	if (strcmp(subDirName, "logs"))
+		leaf << " " << subDirName;
 
 	// If the directory is already there, use it
-	if (subDir.SetTo(subPath.Path()) == B_NO_ERROR) return B_NO_ERROR;
+	if (subDir.SetTo(&baseDir, leaf.String()) == B_NO_ERROR) return B_NO_ERROR;
 
 	// Directory not there?  Shall we create it then?
 	if (createIfNecessary)
 	{
-		BDirectory appDir(path.Path());
-		if ((appDir.InitCheck() == B_NO_ERROR)&&(appDir.CreateDirectory(subDirName, &subDir) == B_NO_ERROR)) return B_NO_ERROR;
+		if (baseDir.CreateDirectory(leaf.String(), &subDir) == B_NO_ERROR) return B_NO_ERROR;
 	}
 	return B_ERROR;  // oops, couldn't get it
 }
-- 
2.2.2


From d30e751890d1a695805ca7abdfa537007441c5eb Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Wed, 29 Apr 2015 21:02:17 +0200
Subject: Minor build fixes.


diff --git a/source/Makefile b/source/Makefile
index abb41d4..003b58f 100644
--- a/source/Makefile
+++ b/source/Makefile
@@ -140,7 +140,7 @@ LOCALES =
 #	use. For example, setting DEFINES to "DEBUG=1" will cause the compiler
 #	option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass
 #	"-DDEBUG" on the compiler's command line.
-DEFINES = MUSCLE_ENABLE_ZLIB_ENCODING \
+DEFINES = _BSD_SOURCE MUSCLE_ENABLE_ZLIB_ENCODING \
 	MUSCLE_AVOID_IPV6 \
 	MUSCLE_NO_EXCEPTIONS \
 	MUSCLE_USE_PTHREADS # \
diff --git a/source/ShareFileTransfer.cpp b/source/ShareFileTransfer.cpp
index 8a067e5..def3488 100644
--- a/source/ShareFileTransfer.cpp
+++ b/source/ShareFileTransfer.cpp
@@ -1631,7 +1631,7 @@ ShareFileTransfer::BeginTransfer()
 		if (startConnect) {
 			if (_mtt) {
 				if ((_mtt->StartInternalThread() == B_NO_ERROR)
-					&& (_mtt->AddNewConnectSession(_remoteHostName(), _remotePort, GetTransferSessionRef()) == B_NO_ERROR))
+					&& (_mtt->AddNewConnectSession(_remoteHostName(), _remotePort, GetTransferSessionRef(), false) == B_NO_ERROR))
 					_isConnecting = true;
 				else
 					((ShareWindow*)Looper())->LogMessage(LOG_ERROR_MESSAGE, str(STR_ERROR_STARTING_DELAYED_CONNECT));
diff --git a/source/ShareNetClient.cpp b/source/ShareNetClient.cpp
index ab0a070..399a846 100644
--- a/source/ShareNetClient.cpp
+++ b/source/ShareNetClient.cpp
@@ -822,7 +822,7 @@ MessageReceived(const MessageRef & msgRef)
 								const char * fileName = GetPathClause(FILE_INFO_DEPTH, nodepath()); 
 								if ((_queryActive)&&(_sessionIDRegExp.Match(sessionID()))&&(_fileNameRegExp.Match(fileName))) 
 								{
-									MessageRef unpacked = InflateMessage(tempRef);
+									MessageRef unpacked = muscle::InflateMessage(tempRef);
 									if (unpacked()) ((ShareWindow *)Looper())->PutResult(sessionID(), fileName, (GetPathClause(USER_NAME_DEPTH, nodepath())[2] == 'r'), unpacked);
 								}
 							}
@@ -944,7 +944,7 @@ AddWatchedDirectory(const node_ref & dirNode, const BEntry & entry, thread_id *
 		
 									nextpath += entryRef.name;
 
-									MessageRef packed = DeflateMessage(nextFileRef, 9, true);
+									MessageRef packed = muscle::DeflateMessage(nextFileRef, 9, true);
 									if (packed())
 									{
 										uploadMsg()->AddMessage(nextpath(), packed);
-- 
2.2.2

