void dumpEffectDescriptor(effect_descriptor_t *desc, char *str, size_t len) { char s[256]; snprintf(str, len, "\nEffect Descriptor %p:\n", desc); strncat(str, "- TYPE: ", len); uuidToString(&desc->uuid, s, 256); snprintf(str, len, "- UUID: %s\n", s); uuidToString(&desc->type, s, 256); snprintf(str, len, "- TYPE: %s\n", s); sprintf(s, "- apiVersion: %08X\n- flags: %08X\n", desc->apiVersion, desc->flags); strncat(str, s, len); sprintf(s, "- name: %s\n", desc->name); strncat(str, s, len); sprintf(s, "- implementor: %s\n", desc->implementor); strncat(str, s, len); }
// This will find the library and UUID tags of the sub effect pointed by the // node, gets the effect descriptor and lib_entry_t and adds the subeffect - // sub_entry_t to the gSubEffectList int addSubEffect(cnode *root) { ALOGV("addSubEffect"); cnode *node; effect_uuid_t uuid; effect_descriptor_t *d; lib_entry_t *l; list_elem_t *e; node = config_find(root, LIBRARY_TAG); if (node == NULL) { return -EINVAL; } l = getLibrary(node->value); if (l == NULL) { ALOGW("addSubEffect() could not get library %s", node->value); return -EINVAL; } node = config_find(root, UUID_TAG); if (node == NULL) { return -EINVAL; } if (stringToUuid(node->value, &uuid) != 0) { ALOGW("addSubEffect() invalid uuid %s", node->value); return -EINVAL; } d = malloc(sizeof(effect_descriptor_t)); if (l->desc->get_descriptor(&uuid, d) != 0) { char s[40]; uuidToString(&uuid, s, 40); ALOGW("Error querying effect %s on lib %s", s, l->name); free(d); return -EINVAL; } #if (LOG_NDEBUG==0) char s[256]; dumpEffectDescriptor(d, s, 256); ALOGV("addSubEffect() read descriptor %p:%s",d, s); #endif if (EFFECT_API_VERSION_MAJOR(d->apiVersion) != EFFECT_API_VERSION_MAJOR(EFFECT_CONTROL_API_VERSION)) { ALOGW("Bad API version %08x on lib %s", d->apiVersion, l->name); free(d); return -EINVAL; } sub_effect_entry_t *sub_effect = malloc(sizeof(sub_effect_entry_t)); sub_effect->object = d; // lib_entry_t is stored since the sub effects are not linked to the library sub_effect->lib = l; e = malloc(sizeof(list_elem_t)); e->object = sub_effect; e->next = gSubEffectList->sub_elem; gSubEffectList->sub_elem = e; ALOGV("addSubEffect end"); return 0; }
INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); timerID = 0; { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); mir_subclassWindow(hwndList, PluginListWndProc); HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ANSI); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADED); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADED); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADEDGRAY); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADEDGRAY); ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); LVCOLUMN col; col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = _T(""); col.cx = 40; ListView_InsertColumn(hwndList, 0, &col); col.pszText = TranslateT("Plugin"); col.cx = 180; ListView_InsertColumn(hwndList, 1, &col); col.pszText = TranslateT("Name"); col.cx = 180;//max = 220; ListView_InsertColumn(hwndList, 2, &col); col.pszText = TranslateT("Version"); col.cx = 75; ListView_InsertColumn(hwndList, 3, &col); ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT); // scan the plugin dir for plugins, cos arPluginList.destroy(); szFilter.Empty(); enumPlugins(dialogListPlugins, (WPARAM)hwndDlg, (LPARAM)hwndList); // sort out the headers ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE); // dll name int w = ListView_GetColumnWidth(hwndList, 1); if (w > 110) { ListView_SetColumnWidth(hwndList, 1, w = 110); } int max = w < 110 ? 189 + 110 - w : 189; ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE); // short name w = ListView_GetColumnWidth(hwndList, 2); if (w > max) ListView_SetColumnWidth(hwndList, 2, max); ListView_SortItems(hwndList, SortPlugins, (LPARAM)hwndDlg); } return TRUE; case WM_NOTIFY: if (lParam) { NMLISTVIEW *hdr = (NMLISTVIEW *)lParam; if (hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom)) { if (hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000)) { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM it; it.mask = LVIF_PARAM | LVIF_STATE; it.iItem = hdr->iItem; if (!ListView_GetItem(hwndList, &it)) break; PluginListItemData *dat = (PluginListItemData*)it.lParam; if (dat->flags & STATIC_PLUGIN) { ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK); return FALSE; } // find all another standard plugins by mask and disable them if ((hdr->uNewState == 0x2000) && dat->stdPlugin != 0) { for (int iRow = 0; iRow != -1; iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL)) { if (iRow != hdr->iItem) { // skip the plugin we're standing on LVITEM dt; dt.mask = LVIF_PARAM; dt.iItem = iRow; if (ListView_GetItem(hwndList, &dt)) { PluginListItemData *dat2 = (PluginListItemData*)dt.lParam; if (dat2->stdPlugin & dat->stdPlugin) {// mask differs // the lParam is unset, so when the check is unset the clist block doesnt trigger int iSave = dat2->stdPlugin; dat2->stdPlugin = 0; ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK); dat2->stdPlugin = iSave; } } } } } if (bOldMode) ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), TRUE); // this here only in "ghazan mode" SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if (hdr->iItem != -1) { int sel = hdr->uNewState & LVIS_SELECTED; HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = hdr->iItem; if (ListView_GetItem(hwndList, &lvi)) { PluginListItemData *dat = (PluginListItemData*)lvi.lParam; TCHAR buf[1024]; ListView_GetItemText(hwndList, hdr->iItem, 2, buf, _countof(buf)); SetDlgItemText(hwndDlg, IDC_PLUGININFOFRAME, sel ? buf : _T("")); ptrT tszAuthor(latin2t(sel ? dat->author : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINAUTHOR, tszAuthor); ptrT tszEmail(latin2t(sel ? dat->authorEmail : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINEMAIL, tszEmail); ptrT p(Langpack_PcharToTchar(dat->description)); SetDlgItemText(hwndDlg, IDC_PLUGINLONGINFO, sel ? p : _T("")); ptrT tszCopyright(latin2t(sel ? dat->copyright : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINCPYR, tszCopyright); ptrT tszUrl(latin2t(sel ? dat->homepage : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINURL, tszUrl); if (!equalUUID(miid_last, dat->uuid)) { char szUID[128]; uuidToString(dat->uuid, szUID, sizeof(szUID)); SetDlgItemTextA(hwndDlg, IDC_PLUGINPID, sel ? szUID : ""); } else SetDlgItemText(hwndDlg, IDC_PLUGINPID, sel ? TranslateT("<none>") : _T("")); } } } if (hdr->hdr.code == PSN_APPLY) { bool needRestart = false; TCHAR bufRestart[1024]; int bufLen = mir_sntprintf(bufRestart, _T("%s\n"), TranslateT("Miranda NG must be restarted to apply changes for these plugins:")); HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); for (int iRow = 0; iRow != -1;) { TCHAR buf[1024]; ListView_GetItemText(hwndList, iRow, 1, buf, _countof(buf)); int iState = ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0); if (!bOldMode && iState != 0x3000) { LVITEM lvi = { 0 }; lvi.mask = LVIF_IMAGE | LVIF_PARAM; lvi.stateMask = -1; lvi.iItem = iRow; lvi.iSubItem = 0; if (ListView_GetItem(hwndList, &lvi)) { lvi.mask = LVIF_IMAGE; PluginListItemData *dat = (PluginListItemData*)lvi.lParam; if (iState == 0x2000) { // enabling plugin if (lvi.iImage == 3 || lvi.iImage == 5) { if (lvi.iImage == 3 && LoadPluginDynamically(dat)) { lvi.iImage = 2; ListView_SetItem(hwndList, &lvi); } else { bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } } else { // disabling plugin if (lvi.iImage == 2 || lvi.iImage == 4) { if (lvi.iImage == 2 && UnloadPluginDynamically(dat)) { lvi.iImage = 3; ListView_SetItem(hwndList, &lvi); } else { bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } } } } iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL); } LoadStdPlugins(); ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), needRestart); if (needRestart) { mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T("\n%s"), TranslateT("Do you want to restart it now?")); if (MessageBox(NULL, bufRestart, _T("Miranda NG"), MB_ICONWARNING | MB_YESNO) == IDYES) CallService(MS_SYSTEM_RESTART, 1, 0); } } } break; case WM_COMMAND: if (HIWORD(wParam) == STN_CLICKED) { switch (LOWORD(wParam)) { case IDC_GETMOREPLUGINS: Utils_OpenUrl("http://miranda-ng.org/downloads/"); break; case IDC_PLUGINEMAIL: case IDC_PLUGINURL: char buf[512]; char *p = &buf[7]; mir_strcpy(buf, "mailto:"); if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), p, _countof(buf) - 7)) Utils_OpenUrl(LOWORD(wParam) == IDC_PLUGINEMAIL ? buf : p); break; } } break; case WM_DESTROY: arPluginList.destroy(); RemoveAllItems(GetDlgItem(hwndDlg, IDC_PLUGLIST)); break; } return FALSE; }
INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { HWND hwndList=GetDlgItem(hwndDlg,IDC_PLUGLIST); LVCOLUMN col; HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus()? ILC_COLOR32 : ILC_COLOR16), 4, 0); ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_UNICODE ); ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_ANSI ); ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_LOADED ); ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_NOTLOADED ); ListView_SetImageList( hwndList, hIml, LVSIL_SMALL ); TranslateDialogDefault(hwndDlg); col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = TranslateT("Plugin"); col.cx = 70;//max = 140; ListView_InsertColumn(hwndList,0,&col); col.pszText=TranslateT("Name"); col.cx = 70;//max = 220; ListView_InsertColumn(hwndList,1,&col); col.pszText=TranslateT("Version"); col.cx=55; ListView_InsertColumn(hwndList,2,&col); col.pszText=_T(""); col.cx=20; ListView_InsertColumn(hwndList,3,&col); //ListView_InsertColumn(hwndList,4,&col); // XXX: Won't work on windows 95 without IE3+ or 4.70 ListView_SetExtendedListViewStyleEx( hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT ); // scan the plugin dir for plugins, cos enumPlugins( dialogListPlugins, ( WPARAM )hwndDlg, ( LPARAM )hwndList ); // sort out the headers { int w, max; ListView_SetColumnWidth( hwndList, 0, LVSCW_AUTOSIZE ); // dll name w = ListView_GetColumnWidth( hwndList, 0 ); if (w>140) { ListView_SetColumnWidth( hwndList, 0, 140 ); w = 140; } max = w<140? 220+140-w:220; ListView_SetColumnWidth( hwndList, 1, LVSCW_AUTOSIZE ); // short name w = ListView_GetColumnWidth( hwndList, 1 ); if (w>max) ListView_SetColumnWidth( hwndList, 1, max ); } return TRUE; } case WM_NOTIFY: { NMLISTVIEW * hdr = (NMLISTVIEW *) lParam; if ( hdr && hdr->hdr.code == LVN_ITEMCHANGED && hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000 ) && IsWindowVisible(hdr->hdr.hwndFrom) ) { HWND hwndList = GetDlgItem(hwndDlg,IDC_PLUGLIST); PluginListItemData* dat; int iRow; LVITEM it; it.mask=LVIF_PARAM | LVIF_STATE; it.iItem = hdr->iItem; if ( !ListView_GetItem( hwndList, &it )) break; dat = ( PluginListItemData* )it.lParam; if ( dat->flags == DEFMOD_DB ) { ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK); return FALSE; } // if enabling and replaces, find all other replaces and toggle off if ( hdr->uNewState & 0x2000 && dat->flags != 0 ) { for ( iRow=0; iRow != -1; ) { if ( iRow != hdr->iItem ) { LVITEM dt; dt.mask = LVIF_PARAM; dt.iItem = iRow; if ( ListView_GetItem( hwndList, &dt )) { PluginListItemData* dat2 = ( PluginListItemData* )dt.lParam; if ( dat2->flags == dat->flags ) { // the lParam is unset, so when the check is unset the clist block doesnt trigger int lParam = dat2->flags; dat2->flags = 0; ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK ); dat2->flags = lParam; } } } iRow = ListView_GetNextItem( hwndList, iRow, LVNI_ALL ); } } ShowWindow( GetDlgItem(hwndDlg, IDC_RESTART ), TRUE ); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); break; } if ( hdr && hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom) && hdr->iItem != -1 ) { TCHAR buf[1024]; int sel = hdr->uNewState & LVIS_SELECTED; HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = hdr->iItem; if ( ListView_GetItem( hwndList, &lvi )) { PluginListItemData* dat = ( PluginListItemData* )lvi.lParam; ListView_GetItemText(hwndList, hdr->iItem, 1, buf, SIZEOF(buf)); SetWindowText(GetDlgItem(hwndDlg,IDC_PLUGININFOFRAME),sel ? buf : _T("")); SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINAUTHOR), sel ? dat->author : "" ); SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINEMAIL), sel ? dat->authorEmail : "" ); { TCHAR* p = LangPackPcharToTchar( dat->description ); SetWindowText(GetDlgItem(hwndDlg,IDC_PLUGINLONGINFO), sel ? p : _T("")); mir_free( p ); } SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINCPYR), sel ? dat->copyright : "" ); SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINURL), sel ? dat->homepage : "" ); if(equalUUID(miid_last, dat->uuid)) SetWindowText(GetDlgItem(hwndDlg,IDC_PLUGINPID), sel ? TranslateT("<none>") : _T("")); else { char szUID[128]; uuidToString( dat->uuid, szUID, sizeof(szUID)); SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINPID), sel ? szUID : "" ); } } } if ( hdr && hdr->hdr.code == PSN_APPLY ) { HWND hwndList=GetDlgItem(hwndDlg,IDC_PLUGLIST); int iRow; int iState; TCHAR buf[1024]; for (iRow=0 ; iRow != (-1) ; ) { ListView_GetItemText(hwndList, iRow, 0, buf, SIZEOF(buf)); iState=ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); SetPluginOnWhiteList(buf, iState&0x2000 ? 1 : 0); iRow=ListView_GetNextItem(hwndList, iRow, LVNI_ALL); } } break; } case WM_COMMAND: if ( HIWORD(wParam) == STN_CLICKED ) { switch (LOWORD(wParam)) { case IDC_PLUGINEMAIL: case IDC_PLUGINURL: { char buf[512]; char * p = &buf[7]; lstrcpyA(buf,"mailto:"); if ( GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), p, SIZEOF(buf) - 7) ) { CallService(MS_UTILS_OPENURL,0,(LPARAM) (LOWORD(wParam)==IDC_PLUGINEMAIL ? buf : p) ); } break; } case IDC_GETMOREPLUGINS: { CallService(MS_UTILS_OPENURL,0,(LPARAM) "http://addons.miranda-im.org/index.php?action=display&id=1" ); break; } } } break; case WM_DESTROY: RemoveAllItems( GetDlgItem( hwndDlg, IDC_PLUGLIST )); break; } return FALSE; }
int loadEffect(cnode *root) { cnode *node; effect_uuid_t uuid; lib_entry_t *l; effect_descriptor_t *d; list_elem_t *e; node = config_find(root, LIBRARY_TAG); if (node == NULL) { return -EINVAL; } l = getLibrary(node->value); if (l == NULL) { ALOGW("loadEffect() could not get library %s", node->value); return -EINVAL; } node = config_find(root, UUID_TAG); if (node == NULL) { return -EINVAL; } if (stringToUuid(node->value, &uuid) != 0) { ALOGW("loadEffect() invalid uuid %s", node->value); return -EINVAL; } d = malloc(sizeof(effect_descriptor_t)); if (!d) { ALOGE("failed to allocate effect descriptor"); return -EINVAL; } if (l->desc->get_descriptor(&uuid, d) != 0) { char s[40]; uuidToString(&uuid, s, 40); ALOGW("Error querying effect %s on lib %s", s, l->name); free(d); return -EINVAL; } #if (LOG_NDEBUG==0) char s[256]; dumpEffectDescriptor(d, s, 256); ALOGV("loadEffect() read descriptor %p:%s",d, s); #endif if (EFFECT_API_VERSION_MAJOR(d->apiVersion) != EFFECT_API_VERSION_MAJOR(EFFECT_CONTROL_API_VERSION)) { ALOGW("Bad API version %08x on lib %s", d->apiVersion, l->name); free(d); return -EINVAL; } e = malloc(sizeof(list_elem_t)); if (!e) { return -ENOMEM; } e->object = d; e->next = l->effects; l->effects = e; // After the UUID node in the config_tree, if node->next is valid, // that would be sub effect node. // Find the sub effects and add them to the gSubEffectList node = node->next; int count = 2; bool hwSubefx = false, swSubefx = false; list_sub_elem_t *sube = NULL; if (node != NULL) { ALOGV("Adding the effect to gEffectSubList as there are sub effects"); sube = malloc(sizeof(list_sub_elem_t)); if (!sube) { ALOGE("failed to allocate sub element list"); return -ENOMEM; } sube->object = d; sube->sub_elem = NULL; sube->next = gSubEffectList; gSubEffectList = sube; } while (node != NULL && count) { if (addSubEffect(node)) { ALOGW("loadEffect() could not add subEffect %s", node->value); // Change the gSubEffectList to point to older list; gSubEffectList = sube->next; free(sube->sub_elem);// Free an already added sub effect sube->sub_elem = NULL; free(sube); return -ENOENT; } sub_effect_entry_t *subEntry = (sub_effect_entry_t*)gSubEffectList->sub_elem->object; effect_descriptor_t *subEffectDesc = (effect_descriptor_t*)(subEntry->object); // Since we return a dummy descriptor for the proxy during // get_descriptor call,we replace it with the correspoding // sw effect descriptor, but with Proxy UUID // check for Sw desc if (!((subEffectDesc->flags & EFFECT_FLAG_HW_ACC_MASK) == EFFECT_FLAG_HW_ACC_TUNNEL)) { swSubefx = true; *d = *subEffectDesc; d->uuid = uuid; ALOGV("loadEffect() Changed the Proxy desc"); } else hwSubefx = true; count--; node = node->next; } // 1 HW and 1 SW sub effect found. Set the offload flag in the Proxy desc if (hwSubefx && swSubefx) { d->flags |= EFFECT_FLAG_OFFLOAD_SUPPORTED; } return 0; }