Skip to content

Commit

Permalink
* Add WHATSAPP_ROAMING_DIRECTORY to README.md
Browse files Browse the repository at this point in the history
* Allow relative paths for WHATSAPP_ROAMING_DIRECTORY
* Update to version 1.4.3
  • Loading branch information
d4koon committed Jan 6, 2019
1 parent 13aca28 commit 3363422
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ If you want to minimize WhatsApp to tray with the close(X)-button, you have 2 op

If you want to set your own path for the WhatsApp-binary(exe), you can do so by using the 'WHATSAPP_STARTPATH'-config in the appData.ini
- For Example "WHATSAPP_STARTPATH=C:\Users\Dakoon\AppData\Local\WhatsApp\WhatsApp.exe"
- Or Relativ "WHATSAPP_STARTPATH=.\..\WhatsApp.exe"
- Or Relativ to the folder in which WhatsappTray.exe lies "WHATSAPP_STARTPATH=.\..\WhatsApp.exe"

For a portable config it is necessary to change the folder in which whatsapp stores data.
This directory is usually C:\Users\<username>\AppData\Roaming\WhatsApp\\IndexedDB\\file__0.indexeddb.leveldb
This can be configured with the WHATSAPP_ROAMING_DIRECTORY-config in the appData.ini
The set path has to replace 'C:\Users\<username>\AppData\Roaming\'. This path has to cotain the WhatsApp-folder.
- For Example "WHATSAPP_ROAMING_DIRECTORY=C:\Users\Dakoon\AppData\Roaming\
- Or Relativ to the folder in which WhatsappTray.exe lies "WHATSAPP_ROAMING_DIRECTORY=.\..\WhatsApp.exe"

## Thanks to:
Nikolay Redko and J.D. Purcell for creating the RBTray-Software (http://rbtray.sourceforge.net/)
2 changes: 1 addition & 1 deletion WhatsappTray/Version.rc2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#define MAJOR 1
#define MINOR 4
#define PATCH 2
#define PATCH 3

#ifdef _DEBUG
#define IS_DEBUG 1
Expand Down
16 changes: 14 additions & 2 deletions WhatsappTray/WhatsAppApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "DirectoryWatcher.h"
#include "AppData.h"
#include "Helper.h"
#include "Logger.h"

#include <regex>
Expand All @@ -46,15 +47,26 @@ std::function<void()> WhatsAppApi::receivedFullInitEvent = NULL;
/// Initialize the class.
void WhatsAppApi::Init()
{
auto leveldbDirectory = std::string(AppData::WhatsappRoamingDirectory.Get());
std::string leveldbDirectory = std::string(AppData::WhatsappRoamingDirectory.Get());

// Add a slash to the end of the path if ther is none.
auto lastCharacter = leveldbDirectory[leveldbDirectory.length() - 1];
if (lastCharacter != '\\') {
leveldbDirectory.append("\\");
}

leveldbDirectory.append("WhatsApp\\IndexedDB\\file__0.indexeddb.leveldb");
leveldbDirectory.append("WhatsApp\\IndexedDB\\file__0.indexeddb.leveldb\\");

fs::path leveldbDirectoryPath(leveldbDirectory);
if (leveldbDirectoryPath.is_relative()) {
fs::path appPath = Helper::GetApplicationFilePath();
auto combinedPath = appPath / leveldbDirectoryPath;
Logger::Info(MODULE_NAME "Init() - Setting leveldb-directory-path to combinedPath:%s", combinedPath.string().c_str());

// Shorten the path by converting to absoltue path.
auto combinedPathCanonical = fs::canonical(combinedPath);
leveldbDirectory = combinedPathCanonical.string();
}

Logger::Info(MODULE_NAME "Init() - Using leveldb-directory:%s", leveldbDirectory.c_str());

Expand Down
15 changes: 11 additions & 4 deletions WhatsappTray/WhatsappTray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include <psapi.h>
#include <filesystem>

namespace fs = std::experimental::filesystem;

#ifdef _DEBUG
constexpr auto CompileConfiguration = "Debug";
#else
Expand Down Expand Up @@ -160,17 +162,22 @@ HWND startWhatsapp()
{
_hwndWhatsapp = findWhatsapp();

std::experimental::filesystem::path waStartPath = std::string(AppData::WhatsappStartpath.Get());
fs::path waStartPath = std::string(AppData::WhatsappStartpath.Get());
std::string waStartPathString;
if (waStartPath.is_relative()) {
std::experimental::filesystem::path appPath = Helper::GetApplicationFilePath();
fs::path appPath = Helper::GetApplicationFilePath();
auto combinedPath = appPath / waStartPath;
waStartPathString = combinedPath.string();

Logger::Info(MODULE_NAME "startWhatsapp() - Starting WhatsApp from combinedPath:%s", combinedPath.string().c_str());

// Shorten the path by converting to absoltue path.
auto combinedPathCanonical = fs::canonical(combinedPath);
waStartPathString = combinedPathCanonical.string();
} else {
waStartPathString = waStartPath.string();
}

Logger::Info(MODULE_NAME "::startWhatsapp() - Starting from path='" + waStartPathString + "'");
Logger::Info(MODULE_NAME "::startWhatsapp() - Starting WhatsApp from canonical-path:'" + waStartPathString + "'");
HINSTANCE hInst = ShellExecuteA(0, NULL, waStartPathString.c_str(), NULL, NULL, SW_NORMAL);
if (hInst <= (HINSTANCE)32) {
MessageBoxA(NULL, (std::string("Error launching WhatsApp from path='") + waStartPathString + "'").c_str(), "WhatsappTray", MB_OK);
Expand Down
2 changes: 1 addition & 1 deletion setupBuildfile.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "WhatsappTray"
#define MyAppVersion "1.4.2"
#define MyAppVersion "1.4.3"
#define MyAppURL "https://github.com/D4koon/WhatsappTray"
#define MyAppExeName "WhatsappTray.exe"

Expand Down

0 comments on commit 3363422

Please sign in to comment.