Exemple #1
0
int
set_device (const char *name, int out)
{
  struct iaxc_audio_device *devs;	/* audio devices */
  int ndevs;			/* audio dedvice count */
  int input, output, ring;	/* audio device id's */
  int i;
  iaxc_audio_devices_get (&devs, &ndevs, &input, &output, &ring);
  for (i = 0; i < ndevs; i++)
    {
      if (devs[i].capabilities & (out ? IAXC_AD_OUTPUT : IAXC_AD_INPUT) &&
	  strcmp (name, devs[i].name) == 0)
	{
	  if (out)
	    {
	      output = devs[i].devID;
	    }
	  else
	    {
	      input = devs[i].devID;
	    }
	  fprintf (stderr, "device %s = %s (%d)\n", out ? "out" : "in", name,
		   devs[i].devID);
	  iaxc_audio_devices_set (input, output, ring);
	  return 1;
	}
    }
  return 0;
}
void InitOptions() {
	hEventOptInit = HookEvent(ME_OPT_INITIALISE, OptInit);
	DBVARIANT dbv;
	if(!DBGetContactSettingTString(0, MODULE, "Host", &dbv)) { 
		options.host = strdup(dbv.pszVal);
		DBFreeVariant(&dbv);
	}
	if(!DBGetContactSettingTString(0, MODULE, "Username", &dbv)) {
		options.username = strdup(dbv.pszVal);
		DBFreeVariant(&dbv);
	}
	if(!DBGetContactSettingTString(0, MODULE, "Password", &dbv)) {
		options.password = strdup(dbv.pszVal);
		DBFreeVariant(&dbv);
	}
	if(!DBGetContactSettingTString(0, MODULE, "CIDName", &dbv)) {
		options.cid_name = strdup(dbv.pszVal);
		DBFreeVariant(&dbv);
	}
	if(!DBGetContactSettingTString(0, MODULE, "CIDNumber", &dbv)) {
		options.cid_number = strdup(dbv.pszVal);
		DBFreeVariant(&dbv);
	}

	iaxc_audio_device *dev;
	int nDevs, in, out, ring;
	iaxc_audio_devices_get(&dev, &nDevs, &in, &out, &ring);
	if(!DBGetContactSettingTString(0, MODULE, "DeviceIn", &dbv)) {
		for(int i = 0; i < nDevs; i++) {
			if((dev[i].capabilities & IAXC_AD_INPUT) && strcmp(dbv.pszVal, dev[i].name) == 0) in = i;
		}
		DBFreeVariant(&dbv);
	}
	if(!DBGetContactSettingTString(0, MODULE, "DeviceOut", &dbv)) {
		for(int i = 0; i < nDevs; i++) {
			if((dev[i].capabilities & IAXC_AD_OUTPUT) && strcmp(dbv.pszVal, dev[i].name) == 0) out = i;
		}
		DBFreeVariant(&dbv);
	}
	/*
	if(!DBGetContactSettingTString(0, MODULE, "DeviceRing", &dbv)) {
		for(int i = 0; i < nDevs; i++) {
			if((dev[i].capabilities & IAXC_AD_RING) && strcmp(dbv.pszVal, dev[i].name) == 0) ring = i;
		}
		DBFreeVariant(&dbv);
	}
	*/

	options.port = DBGetContactSettingDword(0, MODULE, "Port", 4569);
	iaxc_audio_devices_set(in, out, ring);

	options.dlgHotkey = DBGetContactSettingWord(0, MODULE, "DlgHotkey", 0);
	options.pop_dial_in = (DBGetContactSettingByte(0, MODULE, "PopupDial", 1) == 1);
	options.pop_dial_out = (DBGetContactSettingByte(0, MODULE, "PopupDialOut", 0) == 1);
	
	options.mic_boost = (DBGetContactSettingByte(0, MODULE, "MicBoost", 0) == 1);
	iaxc_mic_boost_set(options.mic_boost ? 1 : 0);
	//options.mic_boost = (iaxc_mic_boost_get() != 0);
}
static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch ( msg ) {
	case WM_INITDIALOG:
		TranslateDialogDefault( hwndDlg );

		SetDlgItemText(hwndDlg, IDC_ED_UNAME, options.username);
		SetDlgItemText(hwndDlg, IDC_ED_PW, options.password);
		SetDlgItemText(hwndDlg, IDC_ED_HOST, options.host);
		SetDlgItemText(hwndDlg, IDC_ED_CIDNAME, options.cid_name);
		SetDlgItemText(hwndDlg, IDC_ED_CIDNUM, options.cid_number);
		SetDlgItemInt(hwndDlg, IDC_ED_PORT, options.port, FALSE);
		CheckDlgButton(hwndDlg, IDC_CHK_POPDIALIN, options.pop_dial_in ? TRUE : FALSE);
		CheckDlgButton(hwndDlg, IDC_CHK_POPDIALOUT, options.pop_dial_out ? TRUE : FALSE);
		CheckDlgButton(hwndDlg, IDC_CHK_MICBOOST, options.mic_boost ? TRUE : FALSE);

		{
			iaxc_audio_device *dev;
			int nDevs, in, out, ring, ind;
			iaxc_audio_devices_get(&dev, &nDevs, &in, &out, &ring);
			for(int i = 0; i < nDevs; i++) {
				if(dev[i].capabilities & IAXC_AD_INPUT) {
					ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVIN, CB_ADDSTRING, 0, (LPARAM)dev[i].name);
					SendDlgItemMessage(hwndDlg, IDC_CMB_DEVIN, CB_SETITEMDATA, ind, i);
					if(i == in) SendDlgItemMessage(hwndDlg, IDC_CMB_DEVIN, CB_SETCURSEL, ind, 0);
				}
				if(dev[i].capabilities & IAXC_AD_OUTPUT) {
					ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVOUT, CB_ADDSTRING, 0, (LPARAM)dev[i].name);
					SendDlgItemMessage(hwndDlg, IDC_CMB_DEVOUT, CB_SETITEMDATA, ind, i);
					if(i == out) SendDlgItemMessage(hwndDlg, IDC_CMB_DEVOUT, CB_SETCURSEL, ind, 0);
				}
				/*
				if(dev[i].capabilities & IAXC_AD_RING) {
					ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVRING, CB_ADDSTRING, 0, (LPARAM)dev[i].name);
					SendDlgItemMessage(hwndDlg, IDC_CMB_DEVRING, CB_SETITEMDATA, ind, i);
					if(i == ring) SendDlgItemMessage(hwndDlg, IDC_CMB_DEVRING, CB_SETCURSEL, ind, 0);
				}
				*/
			}
		}
		SendDlgItemMessage(hwndDlg, IDC_HK_DLG, HKM_SETHOTKEY, options.dlgHotkey, 0);

		return FALSE;		
	case WM_COMMAND:
		if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);		
		}
		if ( HIWORD( wParam ) == CBN_SELCHANGE) {
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);		
		}
		if ( HIWORD( wParam ) == BN_CLICKED) {
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);		
		}
		break;
	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code)
		{
			case PSN_APPLY:
				{
					char buffer[512];

					GetDlgItemText(hwndDlg, IDC_ED_UNAME, buffer, 512);
					if(options.username) free(options.username);
					options.username = strdup(buffer);

					GetDlgItemText(hwndDlg, IDC_ED_PW, buffer, 512);
					if(options.password) free(options.password);
					options.password = strdup(buffer);

					GetDlgItemText(hwndDlg, IDC_ED_HOST, buffer, 512);
					if(options.host) free(options.host);
					options.host = strdup(buffer);

					GetDlgItemText(hwndDlg, IDC_ED_CIDNAME, buffer, 512);
					if(options.cid_name) free(options.cid_name);
					options.cid_name = strdup(buffer);

					GetDlgItemText(hwndDlg, IDC_ED_CIDNUM, buffer, 512);
					if(options.cid_number) free(options.cid_number);
					options.cid_number = strdup(buffer);

					DBWriteContactSettingTString(0, MODULE, "Host", options.host);
					DBWriteContactSettingTString(0, MODULE, "Username", options.username);
					DBWriteContactSettingTString(0, MODULE, "Password", options.password);
					DBWriteContactSettingTString(0, MODULE, "CIDName", options.cid_name);
					DBWriteContactSettingTString(0, MODULE, "CIDNumber", options.cid_number);

					iaxc_audio_device *dev;
					int nDevs, in, out, ring, ind;
					iaxc_audio_devices_get(&dev, &nDevs, &in, &out, &ring);

					ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVIN, CB_GETCURSEL, 0, 0);
					in = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVIN, CB_GETITEMDATA, ind, 0);
					ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVOUT, CB_GETCURSEL, 0, 0);
					out = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVOUT, CB_GETITEMDATA, ind, 0);
					//ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVRING, CB_GETCURSEL, 0, 0);
					//ring = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVRING, CB_GETITEMDATA, ind, 0);

					DBWriteContactSettingTString(0, MODULE, "DeviceIn", dev[in].name);
					DBWriteContactSettingTString(0, MODULE, "DeviceOut", dev[out].name);
					//DBWriteContactSettingTString(0, MODULE, "DeviceRing", dev[ring].name);

					BOOL trans;
					int port = GetDlgItemInt(hwndDlg, IDC_ED_PORT, &trans, FALSE);
					if(trans) options.port = port;
					DBWriteContactSettingDword(0, MODULE, "Port", options.port);

					iaxc_audio_devices_set(in, out, ring);

					options.dlgHotkey = (WORD)SendDlgItemMessage(hwndDlg, IDC_HK_DLG, HKM_GETHOTKEY, 0, 0);
					DBWriteContactSettingWord(0, MODULE, "DlgHotkey", options.dlgHotkey);
					ResetDlgHotkey();

					options.pop_dial_in = IsDlgButtonChecked(hwndDlg, IDC_CHK_POPDIALIN) ? true : false;
					options.pop_dial_out = IsDlgButtonChecked(hwndDlg, IDC_CHK_POPDIALOUT) ? true : false;
					DBWriteContactSettingByte(0, MODULE, "PopupDial", options.pop_dial_in ? 1 : 0);
					DBWriteContactSettingByte(0, MODULE, "PopupDialOut", options.pop_dial_out ? 1 : 0);

					options.mic_boost = IsDlgButtonChecked(hwndDlg, IDC_CHK_MICBOOST) ? true : false;
					DBWriteContactSettingByte(0, MODULE, "MicBoost", options.mic_boost ? 1 : 0);
					iaxc_mic_boost_set(options.mic_boost ? 1 : 0);
				}

				return TRUE;
		}
		break;
	}

	return 0;
}
Exemple #4
0
void Prefs::updateDevices()
{
  iaxc_audio_devices_set(inputDevice,outputDevice,ringDevice);
}