mirror of
https://github.com/siemens-mobile-hacks/89_theme_engine.git
synced 2026-11-25 21:47:27 +00:00
Fix IPC
This commit is contained in:
parent
5ba8f3bc87
commit
9c1cecdec3
6 changed files with 38 additions and 17 deletions
|
|
@ -3,11 +3,18 @@
|
|||
|
||||
const char *IPC_NAME = "89ThemeEngine";
|
||||
|
||||
void IPC_SendMessage(int submess, IPC_DATA *data) {
|
||||
static IPC_REQ ipc;
|
||||
IPC_REQ *p = &ipc;
|
||||
p->name_to = IPC_NAME;
|
||||
p->name_from = IPC_NAME;
|
||||
p->data = data;
|
||||
GBS_SendMessage(MMI_CEPID, MSG_IPC, submess, p);
|
||||
void IPC_SendMessage(int submess, IPC_REQ *ipc_req, IPC_DATA *data) {
|
||||
ipc_req->name_to = IPC_NAME;
|
||||
ipc_req->name_from = IPC_NAME;
|
||||
ipc_req->data = data;
|
||||
GBS_SendMessage(MMI_CEPID, MSG_IPC, submess, ipc_req);
|
||||
}
|
||||
|
||||
void IPC_DestroyMessage(IPC_REQ *ipc_req) {
|
||||
if (ipc_req) {
|
||||
if (ipc_req->data) {
|
||||
mfree(ipc_req->data);
|
||||
}
|
||||
mfree(ipc_req);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ typedef struct {
|
|||
void *data2;
|
||||
} IPC_DATA;
|
||||
|
||||
void IPC_SendMessage(int submess, IPC_DATA *data);
|
||||
void IPC_SendMessage(int submess, IPC_REQ *ipc_req, IPC_DATA *data);
|
||||
void IPC_DestroyMessage(IPC_REQ *ipc_req);
|
||||
|
||||
extern const char *IPC_NAME;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void ApplyTheme(MAIN_CSM *csm) {
|
|||
}
|
||||
|
||||
void ApplyThemeTimerProc(GBSTMR *tmr) {
|
||||
IPC_SendMessage(IPC_APPLY_THEME, NULL);
|
||||
ApplyTheme_IPC();
|
||||
}
|
||||
|
||||
void ApplyThemeTimer(MAIN_CSM *csm) {
|
||||
|
|
@ -75,7 +75,9 @@ void ApplyThemeTimer(MAIN_CSM *csm) {
|
|||
|
||||
void ApplyThemeYesNo(const int no) {
|
||||
if (!no) {
|
||||
IPC_SendMessage(IPC_APPLY_THEME, NULL);
|
||||
ApplyTheme_IPC();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,9 +96,9 @@ int GetDefaultSkinPath(char *dest, const char *exe_path) {
|
|||
int OnMessage(CSM_RAM *data, GBS_MSG *msg) {
|
||||
MAIN_CSM *csm = (MAIN_CSM*)data;
|
||||
if (msg->msg == MSG_IPC) {
|
||||
const IPC_REQ *ipc = msg->data0;
|
||||
if (strcmpi(ipc->name_to, IPC_NAME) == 0) {
|
||||
IPC_DATA *ipc_data = ipc->data;
|
||||
IPC_REQ *ipc_req = msg->data0;
|
||||
if (strcmpi(ipc_req->name_to, IPC_NAME) == 0) {
|
||||
IPC_DATA *ipc_data = ipc_req->data;
|
||||
if (msg->submess == IPC_RUN) {
|
||||
const int csm_id = (int)ipc_data->data0;
|
||||
const char *exe_path = ipc_data->data1;
|
||||
|
|
@ -131,6 +133,7 @@ int OnMessage(CSM_RAM *data, GBS_MSG *msg) {
|
|||
} else {
|
||||
MsgBoxError(0x11, (int)"Theme is already being applied");
|
||||
}
|
||||
IPC_DestroyMessage(ipc_req);
|
||||
} else if (msg->submess == IPC_PBAR_STEP) {
|
||||
if (csm->pbar.gui_id) {
|
||||
csm->pbar.current++;
|
||||
|
|
@ -143,7 +146,7 @@ int OnMessage(CSM_RAM *data, GBS_MSG *msg) {
|
|||
SetPBarValue(csm->pbar.gui_id, (int)(100 * percent));
|
||||
}
|
||||
mfree(ipc_data->data0);
|
||||
mfree(ipc_data);
|
||||
IPC_DestroyMessage(ipc_req);
|
||||
}
|
||||
}
|
||||
} else if (msg->msg == MSG_GUI_DESTROYED) {
|
||||
|
|
@ -160,7 +163,7 @@ int OnMessage(CSM_RAM *data, GBS_MSG *msg) {
|
|||
ShowMSG(0x11, (int)"89ThemeEngine config updated!");
|
||||
PatchSettings_Init();
|
||||
} else if (strcmpi(msg->data0, csm->skin_path) == 0) {
|
||||
IPC_SendMessage(IPC_APPLY_THEME, NULL);
|
||||
ApplyTheme_IPC();
|
||||
}
|
||||
} else if (msg->msg == REGISTRY_CLIENT_MSG_ID) {
|
||||
strcpy(csm->skin_path, CFG.skin_path);
|
||||
|
|
@ -234,6 +237,7 @@ int main(const char *exe_path, const char *file_path) {
|
|||
CSM_root()->csm_q->current_msg_processing_csm = save_cmpc;
|
||||
UnlockSched();
|
||||
|
||||
static IPC_REQ ipc_req;
|
||||
static char s_exe_path[128];
|
||||
static char s_file_path[128];
|
||||
static IPC_DATA data = { 0 };
|
||||
|
|
@ -246,7 +250,7 @@ int main(const char *exe_path, const char *file_path) {
|
|||
*s_file_path = 0;
|
||||
}
|
||||
data.data2 = s_file_path;
|
||||
IPC_SendMessage(IPC_RUN, &data);
|
||||
IPC_SendMessage(IPC_RUN, &ipc_req, &data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ PBAR_DESC PBAR_D = {
|
|||
};
|
||||
|
||||
void PBar_Step(PBarTextType type, const char *text) {
|
||||
IPC_REQ *ipc_req = malloc(sizeof(IPC_REQ));
|
||||
IPC_DATA *ipc_data = malloc(sizeof(IPC_DATA));
|
||||
// ReSharper disable once CppDFAMemoryLeak
|
||||
ipc_data->data0 = malloc(64);
|
||||
|
|
@ -35,7 +36,7 @@ void PBar_Step(PBarTextType type, const char *text) {
|
|||
} else {
|
||||
strcpy(ipc_data->data0, "Unknown");
|
||||
}
|
||||
IPC_SendMessage(IPC_PBAR_STEP, ipc_data);
|
||||
IPC_SendMessage(IPC_PBAR_STEP, ipc_req, ipc_data);
|
||||
}
|
||||
|
||||
int PBar_Create() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <swilib.h>
|
||||
#include "ipc.h"
|
||||
#include "skin.h"
|
||||
#include "pbar.h"
|
||||
#include "config.h"
|
||||
|
|
@ -496,3 +497,8 @@ int Theme_Apply() {
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ApplyTheme_IPC() {
|
||||
IPC_REQ *ipc_req = malloc(sizeof(IPC_REQ));
|
||||
IPC_SendMessage(IPC_APPLY_THEME, ipc_req, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
int Theme_Apply();
|
||||
void ApplyTheme_IPC();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue