예제 #1
0
int
init_sound_engine (void)
{
  if (nosound) {
    nosfx = 1;
    return 0;
  }

  dmsg (D_SYSTEM | D_SOUND_TRACK, "initialize libMikMod");

  /* register all the drivers */
  MikMod_RegisterAllDrivers ();
  dmsg (D_SOUND_TRACK, "libMikMod driver registered");

  /* register the all module loader
     (the user can use something else than .xm) */
  MikMod_RegisterAllLoaders ();
  dmsg (D_SOUND_TRACK, "libMikMod loader registered");

  /* initialize the library */
  md_device = nth_driver;
  md_mode |= DMODE_SOFT_MUSIC | DMODE_SOFT_SNDFX;
  if (mono)
    md_mode &= ~DMODE_STEREO;
  if (bits8)
    md_mode &= ~DMODE_16BITS;
  if (hqmix)
    md_mode |= DMODE_HQMIXER;
  dmsg (D_SOUND_TRACK, "Opening audio device #%d, with %dbits, %s%s",
	nth_driver, (md_mode & DMODE_16BITS)?16:8,
	(md_mode & DMODE_STEREO)?"stereo":"mono",
	(md_mode & DMODE_HQMIXER)?"":", high quality mixer");
  if (driver_options)
    dmsg (D_SOUND_TRACK, "MikMod user options: %s", driver_options);
  if (MikMod_Init (driver_options ? driver_options : const_cast_string (""))) {
    wmsg (_("Could not initialize sound, reason: %s\n"
	    "Disabling sound output (use -S to suppress this message)."),
	  MikMod_strerror (MikMod_errno));
    nosfx = nosound = 1;
    MikMod_Exit ();
    return 0;
  }

  dmsg (D_SOUND_TRACK,"initialize MikMod thread");
  if (MikMod_InitThreads () != 1) {
    wmsg (_("Could not initialize sound, reason: "
	    "LibMikMod is not thread safe.\n"
	    "Disabling sound output (use -S to suppress this message)."));
    nosfx = nosound = 1;
    MikMod_Exit ();
    return 0;
  }

  sound_initialized = 1;

  pthread_mutex_init (&playing, 0);
  adjust_volume ();

  return 0;
}
예제 #2
0
FARPROC WINAPI delayHookNotifyFunc(unsigned dliNotify, PDelayLoadInfo pdli)
{
	switch (dliNotify)
	{
	case dliNotePreLoadLibrary:
		char DllPath[MAX_PATH] = { 0 };
		GetModuleFileNameA(g_hModule, DllPath, _countof(DllPath));
		//remove file
		while (DllPath[strlen(DllPath) - 1] != '\\')
			DllPath[strlen(DllPath) - 1] = 0;

		char *platform =
#ifdef _WIN64
			"win64";
#else
			"win32";
#endif
		char buff[1024];
		_snprintf_s(buff, sizeof(buff), "%s..\\..\\resources\\%s\\%s", DllPath, platform, pdli->szDll);


#ifdef _WIN64
		std::string msg = buff;
		std::wstring wmsg(msg.begin(), msg.end());
		return (FARPROC) LoadLibrary(wmsg.c_str());
#else
		return (FARPROC) LoadLibrary(buff);
#endif		
		break;
	}

	return nullptr;
}
예제 #3
0
 void BasicError<wchar_t>::setMsg()
 {
     std::string s = _(errMsg(code_));
     std::wstring wmsg(s.begin(), s.end());
     std::wstring::size_type pos;
     pos = wmsg.find(L"%0");
     if (pos != std::wstring::npos) {
         wmsg.replace(pos, 2, toBasicString<wchar_t>(code_));
     }
     if (count_ > 0) {
         pos = wmsg.find(L"%1");
         if (pos != std::wstring::npos) {
             wmsg.replace(pos, 2, arg1_);
         }
     }
     if (count_ > 1) {
         pos = wmsg.find(L"%2");
         if (pos != std::wstring::npos) {
             wmsg.replace(pos, 2, arg2_);
         }
     }
     if (count_ > 2) {
         pos = wmsg.find(L"%3");
         if (pos != std::wstring::npos) {
             wmsg.replace(pos, 2, arg3_);
         }
     }
     wmsg_ = wmsg;
     msg_ = ws2s(wmsg);
 }
예제 #4
0
void
test_key_encrypt (rabin_priv &sk, schnorr_clnt_priv *scp,
		  schnorr_srv_priv *ssp)
{
  for (int i = 0; i < 10; i++) {
    size_t len = 512;
    wmstr wmsg (len);
    rnd.getbytes (wmsg, len);
    str msg = wmsg;

    startt ();
    ref<ephem_key_pair> ekp = scp->make_ephem_key_pair ();
    eg += stopt ();

    startt ();
    bigint rab = sk.sign (msg);
    rs += stopt ();

    startt();
    if (!sk.verify (msg, rab)) {
      panic << "verify failed.\n";
    }
    rv += stopt ();

    int bitno = rnd.getword () % mpz_sizeinbase2 (&rab);
    rab.setbit (bitno, !rab.getbit (bitno));
    if (sk.verify (msg, rab)) {
      panic << "verify should have failed\n";
    }

    bigint r_srv, s_srv, r, s;
    startt ();
    if (!ssp->endorse_signature (&r_srv, &s_srv, msg, ekp->public_half ())) {
      panic << "cannot endorse\n";
    }
    se += stopt ();
    startt ();
    if (!scp->complete_signature (&r, &s, msg, ekp->public_half (),
				  ekp->private_half (), r_srv, s_srv)) {
      panic << "cannot complete sig\n";
    }
    sc += stopt ();
    
    startt ();
    if (!scp->verify (msg, r, s)) {
      panic << "verify failed\n";
    }
    sv += stopt ();
    bitno = rnd.getword () % mpz_sizeinbase2 (&s);
    s.setbit (bitno, !s.getbit (bitno));
    if (scp->verify (msg, r, s))
      panic << "verify should have failed.\n";

    /*
    warn << "Success: " << i << "\n";
    */
    n++;
  }
}
예제 #5
0
파일: common.c 프로젝트: dardevelin/dutils
void *action_test(void *carry, void *data, void *param)
{
	//allow silent testing
	if (param) {
		wmsg("%d\n", *(int*)data);
	}
	return NULL;
}
예제 #6
0
파일: twin.cpp 프로젝트: glukki/ipmsg
int TWin::MessageBoxU8(LPCSTR msg, LPCSTR title, UINT style)
{
	Wstr	wmsg(msg);
	Wstr	wtitle(title);

	
	return	MessageBoxW(wmsg.s(), wtitle.s(), style);
}
예제 #7
0
static unsigned long int
parse_unsigned (char *token, unsigned long int min, unsigned long int max)
{
  unsigned long int val = strtoul (token, 0, 10);
  if (val < min || val > max) {
    wmsg ("%s:%d: value %s is out of range (%lu-%lu)",
          preferences_file (), firstline, token, min, max);
    val = (val < min) ? min : max;
  }
  return val;
}
예제 #8
0
파일: common.c 프로젝트: dardevelin/dutils
void *int_copy(int n)
{
	int *ptr = malloc( sizeof( int ) );
	if (!ptr) {
		wmsg("%s malloc failed\n", __func__);
		return NULL;
	}

	*ptr = n;
	return ptr;
}
예제 #9
0
FARPROC WINAPI delayHookFailureFunc(unsigned dliNotify, PDelayLoadInfo pdli)
{
	switch (dliNotify)
	{
	case dliFailLoadLib:
		char buff[1024];
		_snprintf_s(buff, sizeof(buff), "Error loading %s, exiting.", pdli->szDll);
		std::string msg = buff;
		std::wstring wmsg(msg.begin(), msg.end());
		MessageBox(nullptr, wmsg.c_str(), L"XBMC: Fatal Error", MB_OK | MB_ICONERROR);		
		break;
	}
	return nullptr;
}
예제 #10
0
void
load_soundtrack (char *ptr)
{
  if (nosound)
    return;
  dmsg (D_FILE|D_SOUND_TRACK,"loading sound track: %s", ptr);
  module = Player_Load (ptr, 16, 0);
  if (!module) {
    wmsg (_("Could not load %s, reason: %s"), ptr,
	  MikMod_strerror (MikMod_errno));
  } else {
    sound_track_loaded = 1;
  }
}
예제 #11
0
WPWEvent::WPWEvent(int type, WUserMap & users, const QString & msg, bool encrypted)
		: QCustomEvent(type)
{
	fWant = false;
	fEncrypted = encrypted;
	if (type == WPWEvent::TextEvent)
	{
		fWant = true;	// this way we'll get an error string in the private window if
		// an invalid command is used
		// everything is stuck into one string
		if (msg.startsWith("/") && !msg.startsWith("//"))
		{
			// just forward the message
			fMsg = msg;
		}
		else
		{
			QString smsg(msg);
			if (smsg.startsWith("//"))
				smsg.replace(0, 2, "/");
			if (fEncrypted)
				fMsg = "/emsg ";
			else
				fMsg = "/msg ";

			QString tusers;
			WUserIter it = users.GetIterator(HTIT_FLAG_NOREGISTER);
			while (it.HasData())
			{
				WUserRef uref;
				uref = it.GetValue();
				AddToList(tusers, uref()->GetUserID());
				it++;
			}

			fMsg += tusers;
			fMsg += " ";
			fMsg += smsg;

#ifdef _DEBUG
			WString wmsg(fMsg);
			PRINT("Sending text: %S\n", wmsg.getBuffer());
#endif
		}
	}
	else
	{
		fMsg = msg;
	}
}
예제 #12
0
파일: esign_test.cpp 프로젝트: sga001/vex
void test_key_sign (esign_priv &sk)
{

  uint8_t zz = 2;
  strbuf y;
  y << str((char*) &zz, 1) << "hello";
  uint8_t yy = (uint8_t) str(y)[0];

  warn << yy << "\n";

  esign_pub pk = get_public_key();

  bool ret;
  for (int i = 0; i < 25000; i++) {
    size_t len = rnd.getword () % 256;
    wmstr wmsg (len);
    rnd.getbytes (wmsg, len);
    str msg1 = wmsg;

    bigint m = sk.sign (msg1);

    // test converting back and forth
    std::vector<uint8_t> raw_m;
    
    get_raw_bigint(m, &raw_m);
    m = get_bigint_raw(raw_m); 

    ret = pk.verify (msg1, m);

    if (!ret)
      panic << "Verify failed\n"
	    << "  p = " << sk.p << "\n"
	    << "  q = " << sk.q << "\n"
	    << "msg = " << hexdump (msg1.cstr (), msg1.len ()) << "\n"
	    << "sig = " << m << "\n";
    
    int bitno = rnd.getword () % mpz_sizeinbase2 (&m);
    m.setbit (bitno, !m.getbit (bitno));
    
    if (pk.verify (msg1, m)) {
      panic << "Verify should have failed\n"
	    << "  p = " << sk.p << "\n"
	    << "  q = " << sk.q << "\n"
	    << "msg = " << hexdump (msg1.cstr (), msg1.len ()) << "\n"
	    << "sig = " << m << "\n";
    } 
  }
}
예제 #13
0
bool
save_preferences (void)
{
  FILE* fs;

  dmsg (D_MISC, "save preferences to %s", preferences_file ());
  fs = fopen (preferences_file (), "wt");
  if (fs == 0) {
     wmsg ("cannot save preferences to %s", preferences_file ());
     dperror ("fopen");
     return true;
  }
  output_preferences (fs);
  fclose (fs);
  return false;
}
예제 #14
0
파일: common.c 프로젝트: dardevelin/dutils
void *action_reverse_print_test(void *carry, void *data, void *param)
{
	static int max;
	//it's our first time, set the data
	if (!carry) {
		max = 1000;
	}

	//allow test
	if (param) {
		wmsg("\t:(max=%4.d ? data=%4.d) -> %c\n",
		     max, *(int*)data, (max == *(int*)data ? 'T' : 'F') );
	}

	assert( max == *(int*)data );

	--max;
	return data;
}
void
test_key_sign (dsa_priv *sk)
{
  u_int64_t tmp1, tmp2, tmp3;

  for (int i = 0; i < 50; i++) {
    bigint r, s;

    size_t len = 512;
    wmstr wmsg (len);
    rnd.getbytes (wmsg, len);
    str msg = wmsg;

    tmp1 = get_time ();
    sk->sign (&r, &s, msg);
    tmp2 = get_time ();

    if (!sk->verify (msg, r, s))
      panic << "Verify failed\n"
	    << "  p = " << sk->p << "\n"
	    << "  q = " << sk->q << "\n"
	    << "  g = " << sk->g << "\n"
	    << "  x = " << sk->x << "\n"
	    << "  y = " << sk->y << "\n"
	    << "msg = " << hexdump (msg.cstr (), msg.len ()) << "\n"
	    << "sig.r = " << r << "\n"
	    << "sig.s = " << s << "\n";
    tmp3 = get_time ();

    tst_vtime += (tmp3 - tmp2);
    tst_stime += (tmp2 - tmp1);

    int bitno = rnd.getword () % mpz_sizeinbase2 (&r);
    r.setbit (bitno, !r.getbit (bitno));
    if (sk->verify (msg, r, s))
      panic << "Verify should have failed\n";

    bitno = rnd.getword () % mpz_sizeinbase2 (&s);
    s.setbit (bitno, !s.getbit (bitno));
    if (sk->verify (msg, s, s))
      panic << "Verify should have failed\n";
  }
}
status_t
SoundplayThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
{
	BMessage uisettings;
	status_t err;
	rgb_color panelcol;
	int32 wincnt = 1;
	
	err = theme.FindMessage(Z_THEME_UI_SETTINGS, &uisettings);
	if (err)
		return err;
	
	if (FindRGBColor(uisettings, B_UI_PANEL_BACKGROUND_COLOR, 0, &panelcol) < B_OK)
		panelcol = make_color(216,216,216,255);
	
	if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) {
		// WRITEME
	}

	if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) {
		BMessenger msgr(kSoundPlaySig);
		BMessage command(B_COUNT_PROPERTIES);
		BMessage answer;
		command.AddSpecifier("Window");
		err = msgr.SendMessage(&command, &answer,2000000LL,2000000LL);
		if(B_OK == err) {
			if (answer.FindInt32("result", &wincnt) != B_OK)
				wincnt = 1;
		}
		BMessage msg(B_PASTE);
		AddRGBColor(msg, "RGBColor", panelcol);
		msg.AddPoint("_drop_point_", BPoint(0,0));
		// send to every window (the Playlist window needs it too)
		for (int32 i = 0; i < wincnt; i++) {
			BMessage wmsg(msg);
			wmsg.AddSpecifier("Window", i);
			msgr.SendMessage(&wmsg, (BHandler *)NULL, 2000000LL);
		}
	}
	
	return B_OK;
}
예제 #17
0
void TMainDlg::WriteErrLogNoUI(const char *msg)
{
	EnableErrLogFile(TRUE);

	WriteLogHeader(hErrLog);

	DWORD	len, size;
	len = (DWORD)strlen(msg);

	::WriteFile(hErrLog, msg, len, &size, 0);
	::WriteFile(hErrLog, "\r\n\r\n", 4, &size, 0);

	if (::AttachConsole(ATTACH_PARENT_PROCESS)) {
		HANDLE	hStdErr = GetStdHandle(STD_ERROR_HANDLE);
		Wstr	wmsg(msg);
		::WriteConsoleW(hStdErr, L"FastCopy: ", 10, &size, 0);
		::WriteConsoleW(hStdErr, wmsg.s(), (DWORD)wcslen(wmsg.s()), &size, 0);
		::WriteConsoleW(hStdErr, L"\r\n\r\n", 4, &size, 0);
	}

	EnableErrLogFile(FALSE);
}
예제 #18
0
void
test_key_sign (esign_priv &sk)
{
  u_int64_t tmp, tmp2, tmp3;
  bool ret;
  for (int i = 0; i < 50; i++) {
    size_t len = rnd.getword () % 256;
    wmstr wmsg (len);
    rnd.getbytes (wmsg, len);
    str msg1 = wmsg;

    tmp = get_time ();
    bigint m = sk.sign (msg1);
    tmp2 = get_time ();
    ret = sk.verify (msg1, m);
    tmp3 = get_time ();

    vtime += (tmp3 - tmp2);
    signtime += (tmp2 - tmp);

    if (!ret)
      panic << "Verify failed\n"
	    << "  p = " << sk.p << "\n"
	    << "  q = " << sk.q << "\n"
	    << "msg = " << hexdump (msg1.cstr (), msg1.len ()) << "\n"
	    << "sig = " << m << "\n";
    int bitno = rnd.getword () % mpz_sizeinbase2 (&m);
    m.setbit (bitno, !m.getbit (bitno));
    if (sk.verify (msg1, m))
      panic << "Verify should have failed\n"
	    << "  p = " << sk.p << "\n"
	    << "  q = " << sk.q << "\n"
	    << "msg = " << hexdump (msg1.cstr (), msg1.len ()) << "\n"
	    << "sig = " << m << "\n";
  }
}
예제 #19
0
파일: logmng.cpp 프로젝트: shirouzu/ipmsg
BOOL LogMng::WriteMsg(ULONG packetNo, LPCSTR msg, ULONG command, int opt, time_t t,
	ShareInfo *shareInfo, int64 *msg_id)
{
	U8str	buf(MAX_UDPBUF);
	char	*p = buf.Buf();

	if (msg_id) {
		*msg_id = 0;
	}

	p += strcpyz(p, LOGMSG_AT);
	p += strcpyz(p, Ctime(&t)); 
	p += strcpyz(p, " ");

	logMsg->packet_no = packetNo;
	logMsg->date = t;

	if (command & IPMSG_BROADCASTOPT) {
		p += strcpyz(p, LoadStrU8(IDS_BROADCASTLOG));
	}

	if (command & IPMSG_AUTORETOPT) {
		p += strcpyz(p, LoadStrU8(IDS_AUTORETLOG));
		logMsg->flags |= DB_FLAG_AUTOREP;
	}

	if (command & IPMSG_MULTICASTOPT) {
		p += strcpyz(p, LoadStrU8(IDS_MULTICASTLOG));
		logMsg->flags |= DB_FLAG_MULTI;
	}

	if (command & IPMSG_ENCRYPTOPT) {
		int		id = 0;
		if (opt & LOG_SIGN2_OK) {
			id = IDS_ENCRYPT2_SIGNED2;
			logMsg->flags |= DB_FLAG_SIGNED2|DB_FLAG_RSA2;
		}
		else if (opt & LOG_SIGN_OK) {
			id = IDS_ENCRYPT2_SIGNED;
			logMsg->flags |= DB_FLAG_SIGNED|DB_FLAG_RSA2;
		}
		else if (opt & LOG_SIGN_ERR) {
			id = IDS_ENCRYPT2_ERROR;
			logMsg->flags |= DB_FLAG_SIGNERR|DB_FLAG_RSA2;
		}
		else if (opt & LOG_ENC2) {
			id = IDS_ENCRYPT2;
			logMsg->flags |= DB_FLAG_RSA2;
		}
		else {
			id = IDS_ENCRYPT;
			logMsg->flags |= DB_FLAG_RSA;
		}
		p += strcpyz(p, LoadStrU8(id));
	}
	else if (opt & LOG_UNAUTH) {
		p += strcpyz(p, LoadStrU8(IDS_UNAUTHORIZED));
		logMsg->flags |= DB_FLAG_UNAUTH;
	}

	if (command & IPMSG_SECRETOPT)
	{
		if (command & IPMSG_PASSWORDOPT) {
			p += strcpyz(p, LoadStrU8(IDS_PASSWDLOG));
		}
		else {
			p += strcpyz(p, LoadStrU8(IDS_SECRETLOG));
		}
		logMsg->flags |= DB_FLAG_SEAL;

		// 未開封フラグのセット
		for (auto itr=logMsg->host.begin(); itr != logMsg->host.end(); itr++) {
			if ((logMsg->flags & DB_FLAG_FROM) == 0 || itr == logMsg->host.begin()) {
				itr->flags = DB_FLAGMH_UNOPEN;
			}
		}
		if ((logMsg->flags & DB_FLAG_FROM)) {
			logMsg->flags |= DB_FLAG_UNOPENR;
		}
	}
	if (opt & LOG_DELAY) {
		p += strcpyz(p, LoadStrU8(IDS_DELAYSEND));
		logMsg->flags |= DB_FLAG_DELAY;
	}

	if (shareInfo && (command & IPMSG_FILEATTACHOPT))
	{
		int	clip_num = 0;
		int	noclip_num = 0;

		for (int i=0; i < shareInfo->fileCnt; i++) {
			if (GET_MODE(shareInfo->fileInfo[i]->Attr()) == IPMSG_FILE_CLIPBOARD) {
				clip_num++;
			}
			else {
				noclip_num++;
			}
		}
		p += strcpyz(p, "\r\n  ");
		if (clip_num || noclip_num) {
			int id = clip_num ? noclip_num ? IDS_FILEWITHCLIP : IDS_WITHCLIP : IDS_FILEATTACH;
			p += strcpyz(p, LoadStrU8(id));
			p += strcpyz(p, " ");
		}

		for (int i=0; i < shareInfo->fileCnt && p - buf.Buf() < MAX_BUF; i++)
		{
			char	fname[MAX_PATH_U8];
			ForcePathToFname(shareInfo->fileInfo[i]->Fname(), fname);
			p += snprintfz(p, MAX_BUF, "%s%s", fname, i+1 == shareInfo->fileCnt ? "" : ", ");

			if (GET_MODE(shareInfo->fileInfo[i]->Attr()) == IPMSG_FILE_CLIPBOARD) {
				LogClip	clip;
				clip.fname = fname;
				SetClipDimension(cfg, &clip);
				logMsg->clip.push_back(clip);
				logMsg->flags |= DB_FLAG_CLIP;
			}
			else {
				logMsg->files.push_back(fname);
				logMsg->flags |= DB_FLAG_FILE;
			}
		}
	}
	p += strcpyz(p, "\r\n");
	p += strcpyz(p, LOGMSG_HEAD_END);

	Wstr	wmsg(msg);
	LocalNewLineToUnixW(wmsg.s(), wmsg.Buf(), wmsg.Len()+1);
	logMsg->body = wmsg;
	logMsg->lines = get_linenum_n(logMsg->body.s(), logMsg->body.StripLen());

	BOOL ret = Write(buf.s()) && Write(msg) && Write("\r\n\r\n");

#ifdef IPMSG_PRO
#define LOGMNG_WRITEMSG
#include "miscext.dat"
#undef  LOGMNG_WRITEMSG
#endif


	if (logDb && cfg->LogCheck) {
		logDb->InsertOneData(logMsg);
		PostMessage(GetMainWnd(), WM_LOGVIEW_UPDATE,
			MakeMsgIdHigh(logMsg->msg_id), MakeMsgIdLow(logMsg->msg_id));
		if (msg_id) {
			*msg_id = logMsg->msg_id;
		}
	}
	logMsg->Init();

	return	ret;
}
예제 #20
0
int main(int argc, char **argv)
{

	{
		void *data = NULL;
		void *qata = NULL;
		wmsg("testing defaul functions\n");

		wmsg("int_copy");
		assert( !data && !qata );
		data = int_copy(10);
		qata = int_copy(10);
		assert( data && 10 == *(int*)data );
		assert( qata && 10 == *(int*)qata );


		//clean up
		free(data);
		free(qata);

		wmsg("[OK]\n");
	}

	{
		void *data = NULL;

		data = int_copy(10);

		wmsg("print_test");
		assert( -1 == print_test_global );
		assert( (print_test(data), !print_test_global) );

		free(data);
		wmsg("[OK]\n");
	}

	{
		void *data = NULL;
		void *qata = NULL;

		data = int_copy(10);
		qata = int_copy(10);

		wmsg("cmp_int");
		assert( !cmp_int(data, qata) );

		//clean up
		free(data);
		free(qata);

		wmsg("[OK]\n");
	}

	{
		void *data = NULL;

		wmsg("int_dalloc");

		data = int_copy(10);
		int_dalloc(data);

		wmsg("[OK]\n");
	}

	{
		void *data = NULL;
		data = int_copy(10);

		wmsg("action_test");
		assert( !action_test(NULL, data, NULL) );

		free(data);

		wmsg("[OK]\n");
	}

	{
		void *data = NULL;
		data = int_copy(1000);

		wmsg("action_reverse_print_test");
		assert( 1000 == *(int*)action_reverse_print_test(NULL, data, NULL) );

		free(data);

		wmsg("[OK]\n");

	}

	return 0;
}
예제 #21
0
status_t
WinampSkinThemesAddon::SetSPSkin(BString *from)
{
	status_t err;
	BPath p;
	err = SPSkinPath(&p);
	if (err < B_OK)
		return err;
	p.Append(from->String());
	err = p.InitCheck();
	if (err < B_OK)
		return err;

	/* update the prefs file */
	BPath SPSPath;
	BMessage settings;
	
	if (!from)
		return EINVAL;
	if (from->Length() >= B_PATH_NAME_LENGTH)
		return B_NAME_TOO_LONG;
	
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &SPSPath) < B_OK)
		return B_ERROR;
	BString leaf(SP_SETTINGS_NAME);
	BString user(getenv("USER"));
	user.RemoveFirst("USER="******"$USER", user.String());
	SPSPath.Append(leaf.String());
	PRINT(("SPP %s\n", SPSPath.Path()));
	BFile SPSettings(SPSPath.Path(), B_READ_WRITE);
	PRINT(("SP:BFile\n"));
	if (SPSettings.InitCheck() < B_OK)
		return SPSettings.InitCheck();
	PRINT(("SP:BFile::InitCheck\n"));
	//SPSettings.WriteAt(0x8LL, from->String(), from->Length()+1);
	if (settings.Unflatten(&SPSettings) < B_OK)
		return EIO;
	PRINT(("SP:Unflatten\n"));
	settings.ReplaceString("skinname", p.Path());
	PRINT(("SP:Replace\n"));
	SPSettings.Seek(0LL, SEEK_SET);
	if (settings.Flatten(&SPSettings) < B_OK)
		return EIO;
	PRINT(("SP:Flatten\n"));
	
	/* then tell the app */
	/* first make sure the native BeOS is shown (the 'sk!n' message toggles, wonder Why TF...) */
	bool beosIfaceHidden;
	BMessenger msgr(SP_APP_SIG);
	
	BMessage command(B_GET_PROPERTY);
	BMessage answer;
	command.AddSpecifier("Hidden");
	command.AddSpecifier("Window", 0L); // TitleSpectrumAnalyzer does change the title from "SoundPlay"!
	err = msgr.SendMessage(&command, &answer,(bigtime_t)2E6,(bigtime_t)2E6);
	if(B_OK == err) {
		if (answer.FindBool("result", &beosIfaceHidden) != B_OK)
			beosIfaceHidden = false;
	} else {
		PRINT(("WinampSkinThemesAddon: couldn't talk to SoundPlay: error 0x%08lx\n", err));
		return EIO;
	}	

	BMessage msg('sk!n');
	msg.AddString("path", p.Path());
	msg.PrintToStream();
	if (!beosIfaceHidden) { // native GUI is active
		// -> sending the message to the App will make ituse the skin for all tracks
		PRINT(("SP:Sending to app\n"));
		msgr.SendMessage(&msg, (BHandler *)NULL, 500000);
	} else { // native GUI is hidden (= winamp GUI used)
		int32 wincnt;
		command.MakeEmpty();
		command.what = B_COUNT_PROPERTIES;
		answer.MakeEmpty();
		command.AddSpecifier("Window");
		err = msgr.SendMessage(&command, &answer,(bigtime_t)2E6,(bigtime_t)2E6);
		if(B_OK == err) {
			if (answer.FindInt32("result", &wincnt) != B_OK)
				wincnt = 1;
		} else {
			PRINT(("WinampSkinThemesAddon: couldn't talk to SoundPlay: (2) error 0x%08lx\n", err));
			return EIO;
		}
		// send to all windows but first one.
		for (int32 i = 1; i < wincnt; i++) {
			BMessage wmsg(msg);
			PRINT(("SP:Sending to window %ld\n", i));
			wmsg.AddSpecifier("Window", i);
			wmsg.PrintToStream();
			msgr.SendMessage(&wmsg, (BHandler *)NULL, 500000);
		}
	}
	return B_OK;
}
	void CreoMessageDialog(const string msg, ProUIMessageType type)
	{
		wstring wmsg(msg.begin(),msg.end());
		CreoMessageDialog(wmsg.c_str(), type);
	}