Ejemplo n.º 1
0
ECode CWallpaperManager::SetStream(
    /* [in] */ IInputStream* data)
{
    if (sGlobals->mService == NULL) {
        Slogger::W(TAG, "WallpaperService not running");
        return NOERROR;
    }
    // try {
    AutoPtr<IParcelFileDescriptor> fd;
    FAIL_RETURN(sGlobals->mService->SetWallpaper(String(NULL), (IParcelFileDescriptor**)&fd));
    if (fd == NULL) {
        return NOERROR;
    }
    AutoPtr<IFileOutputStream> fos;
    // try {
    AutoPtr<IFileDescriptor> des;
    fd->GetFileDescriptor((IFileDescriptor**)&des);
    ASSERT_SUCCEEDED(CFileOutputStream::New(des, (IFileOutputStream**)&fos));
    // fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
    SetWallpaper(data, fos);
    // } finally {
    if (fos != NULL) {
        fos->Close();
    }
    fd->Close();
    return NOERROR;
    // }
    // } catch (RemoteException e) {
    //     // Ignore
    // }
}
Ejemplo n.º 2
0
ECode CWallpaperManager::SetResource(
    /* [in] */ Int32 resid)
{
    if (sGlobals->mService == NULL) {
        Slogger::W(TAG, "WallpaperService not running");
        return NOERROR;
    }
    // try {
    AutoPtr<IResources> resources;
    ASSERT_SUCCEEDED(mContext->GetResources((IResources**)&resources));
    String name;
    resources->GetResourceName(resid, &name);
    /* Set the wallpaper to the default values */
    AutoPtr<IParcelFileDescriptor> fd;
    FAIL_RETURN(sGlobals->mService->SetWallpaper(
            String("res:") + name, (IParcelFileDescriptor**)&fd));
    if (fd != NULL) {
        AutoPtr<IFileOutputStream> fos;
        // try {
        // fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
        AutoPtr<IFileDescriptor> des;
        fd->GetFileDescriptor((IFileDescriptor**)&des);
        ASSERT_SUCCEEDED(CFileOutputStream::New(des, (IFileOutputStream**)&fos));
        AutoPtr<IInputStream> res;
        ASSERT_SUCCEEDED(resources->OpenRawResource(resid, (IInputStream**)&res));
        SetWallpaper(res, fos);
        if (fos != NULL) {
            fos->Close();
        }
        fd->Close();
        // } finally {
        //     if (fos != null) {
        //         fos.close();
        //     }
        // }
    }
    // } catch (RemoteException e) {
    //     // Ignore
    // }
    return NOERROR;
}
Ejemplo n.º 3
0
void CSAORI::exec(const CSAORIInput &in, CSAORIOutput &out)
{
	DWORD dwStyle = 3;
	if (in.args.empty())
	{
		out.result_code = SAORIRESULT_BAD_REQUEST;
		return;
	}
	if (in.args.size() > 1)
	{
		dwStyle = _wtoi(in.args[1].c_str());
	}
	if (SetWallpaper(in.args[0].c_str(), dwStyle))
	{
		out.result_code = SAORIRESULT_OK;
	}
	else
	{
		out.result_code = SAORIRESULT_INTERNAL_SERVER_ERROR;
	}
}
Ejemplo n.º 4
0
INT_PTR CALLBACK
BackgroundPageProc(HWND hwndDlg,
                   UINT uMsg,
                   WPARAM wParam,
                   LPARAM lParam)
{
    PDATA pData;

    pData = (PDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);

    switch (uMsg)
    {
        case WM_INITDIALOG:
            pData = (DATA*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DATA));
            SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pData);
            InitBackgroundDialog(hwndDlg, pData);
            break;

        case WM_COMMAND:
            {
                DWORD controlId = LOWORD(wParam);
                DWORD command   = HIWORD(wParam);

                switch (controlId)
                {
                    case IDC_COLOR_BUTTON:
                        if (command == BN_CLICKED)
                            OnColorButton(hwndDlg, pData);
                        break;

                    case IDC_BROWSE_BUTTON:
                        if (command == BN_CLICKED)
                            OnBrowseButton(hwndDlg, pData);
                        break;

                    case IDC_PLACEMENT_COMBO:
                        if (command == CBN_SELCHANGE)
                        {
                            pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);

                            InvalidateRect(GetDlgItem(hwndDlg, IDC_BACKGROUND_PREVIEW), NULL, TRUE);

                            PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                        }
                        break;
                }
            } break;

        case WM_DRAWITEM:
            {
                LPDRAWITEMSTRUCT drawItem;
                drawItem = (LPDRAWITEMSTRUCT)lParam;

                if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
                {
                    DrawBackgroundPreview(drawItem, pData);
                }

            }
            break;

        case WM_NOTIFY:
            {
                LPNMHDR lpnm = (LPNMHDR)lParam;

                switch(lpnm->code)
                {
                    case PSN_APPLY:
                        if(pData->bWallpaperChanged)
                            SetWallpaper(pData);
                        if(pData->bClrBackgroundChanged)
                            SetDesktopBackColor(hwndDlg, pData);
                        SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)_T(""));
                        return TRUE;

                    case LVN_ITEMCHANGED:
                        {
                            LPNMLISTVIEW nm = (LPNMLISTVIEW)lParam;

                            if ((nm->uNewState & LVIS_SELECTED) == 0)
                                return FALSE;

                            ListViewItemChanged(hwndDlg, pData, nm->iItem);
                        }
                        break;
                }
            }
            break;

        case WM_DESTROY:
            if (pData->pWallpaperBitmap != NULL)
                DibFreeImage(pData->pWallpaperBitmap);

            DeleteObject(pData->hBitmap);
            HeapFree(GetProcessHeap(), 0, pData);
            break;
    }

    return FALSE;
}
Ejemplo n.º 5
0
//bWay:
//	true: From File List
bool CWallChangerDlg::SetRandWallPager()
{
	if (!m_muxSetRandWallPager.Lock(0))
		return false;

#define RETURN(x) {																	\
	if (x) {																		\
		m_staticNowPicPath.SetWindowText(m_sNowPicPath);							\
		pTheTray->SetTrayTip(m_sNowPicPath);										\
	} else {																		\
		m_staticNowPicPath.SetWindowText(m_sNowPicPath + _T(" -- ") +				\
			CResString(IDS_WALL_SETWALLPAGERFAIL));									\
		m_sNowPicPath = _T("");														\
		pTheTray->SetTrayTip(_T(""));												\
	}																				\
	m_muxSetRandWallPager.Unlock(); return (x);										\
}

	m_staticNowPicPath.SetWindowText(CResString(IDS_WALL_SETTINGWALLPAGER));
	m_sNowPicPath = GetRandPicPath();

	if (m_sNowPicPath.IsEmpty())
		RETURN(false);
	m_staticNowPicPath.SetWindowText(m_sNowPicPath + _T(" -- ") + CResString(IDS_WALL_SETTINGWALLPAGER));

	m_imgNowPic.Destroy();
	if (m_imgNowPic.Load(m_sNowPicPath)) {
		if (AutoPicSize(m_imgNowPic)) {
			m_imgNowPic.Save(m_sTempFilePath, CXIMAGE_FORMAT_JPG);
			SetWallpaper(m_sTempFilePath, WPSTYLE_CENTER);
		} else {
			SetWallpaper(m_sNowPicPath, WPSTYLE_CENTER);
		}
		RETURN(true);
	} else {
		// IDYES:		delete picture file
		// IDNO:		goto directory
		// IDCANCEL:	do nothing
		int iRes = IDCANCEL;
		CString sComboxMsg = ::g_pWallConf->m_General_sComboxMsg;
		if (sComboxMsg == CResString(IDS_WALL_COMBOX_NULL)) {
			iRes = IDCANCEL;
		} else if (sComboxMsg == CResString(IDS_WALL_COMBOX_DELETE)) {
			DeletePicFile(m_sNowPicPath, false);
			RETURN(false);
		} else if (sComboxMsg == CResString(IDS_WALL_COMBOX_ASKDELETE)) {
			iRes = IDYES;
		} else if (sComboxMsg == CResString(IDS_WALL_COMBOX_EXPLORE)) {
			iRes = IDNO;
		} else {
			CString sMsg;
			sMsg.Format(_T("%s\n%s"), m_sNowPicPath, CResString(IDS_WALL_MSG_IMAGELOADERROR));

			iRes = MessageBox(sMsg, NULL, MB_YESNOCANCEL | MB_ICONQUESTION);

			//CStringArray saBtnText;
			//saBtnText.SetSize(3);
			//saBtnText[0] = CResString(IDS_WALL_MSG_IMAGELOADERROR_BTN1);
			//saBtnText[1] = CResString(IDS_WALL_MSG_IMAGELOADERROR_BTN2);
			//saBtnText[2] = CResString(IDS_WALL_MSG_IMAGELOADERROR_BTN3);
			//switch(CKDMessageBox(_T("WallChanger"), sMsg, saBtnText, this, 2, 3, KDMSG_F_CANCANCEL)) {
			//case 1:
			//	iRes = IDYES;
			//	break;
			//case 2:
			//	iRes = IDNO;
			//	break;
			//default:
			//	iRes = IDCANCEL;
			//	break;
			//}
		}

		if ((iRes == IDYES) && PathFileExists(m_sNowPicPath)) {
			DeletePicFile(m_sNowPicPath, true);
			RETURN(false);
		} else if (iRes == IDNO) {
			CString sBuf = m_sNowPicPath;
			PathRemoveFileSpec(sBuf.GetBuffer());
			sBuf.ReleaseBuffer();
			ShellExecute(m_hWnd, _T("open"), sBuf, NULL, NULL, SW_SHOW);
		}

		RETURN(false);
	}

#undef RETURN
}