htiextension/com.nokia.s60tools.hticonnection/src/com/nokia/s60tools/hticonnection/services/screencaptureservice/ScreenCaptureService.java
changeset 0 61163b28edca
child 9 e67492608de0
equal deleted inserted replaced
-1:000000000000 0:61163b28edca
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 package com.nokia.s60tools.hticonnection.services.screencaptureservice;
       
    19 
       
    20 import com.nokia.s60tools.hticonnection.core.RequestQueueManager;
       
    21 import com.nokia.s60tools.hticonnection.core.RequestResult;
       
    22 import com.nokia.s60tools.hticonnection.exceptions.ConnectionException;
       
    23 import com.nokia.s60tools.hticonnection.exceptions.HTIException;
       
    24 import com.nokia.s60tools.hticonnection.exceptions.ServiceShutdownException;
       
    25 import com.nokia.s60tools.hticonnection.services.HTIScreenMode;
       
    26 import com.nokia.s60tools.hticonnection.services.IScreenCaptureService;
       
    27 import com.nokia.s60tools.util.console.IConsolePrintUtility;
       
    28 
       
    29 /**
       
    30  * Service that contains interface for capturing images from device.
       
    31  */
       
    32 public class ScreenCaptureService implements IScreenCaptureService{
       
    33 	
       
    34 	/**
       
    35 	 * Print utility used to report errors, warnings, and info messages.
       
    36 	 */
       
    37 	private final IConsolePrintUtility printUtility;
       
    38 
       
    39 	/**
       
    40 	 * Constructor.
       
    41 	 * @param printUtility Used for printing messages.
       
    42 	 */
       
    43 	public ScreenCaptureService(IConsolePrintUtility printUtility){
       
    44 		this.printUtility = printUtility;
       
    45 	}
       
    46 	
       
    47 	/* (non-Javadoc)
       
    48 	 * @see com.nokia.s60tools.hticonnection.services.IScreenCaptureService#captureFullScreen(java.lang.String, int, long)
       
    49 	 */
       
    50 	public byte[] captureFullScreen(String imgMimeType, int colorDepth, long timeout) 
       
    51 								throws ServiceShutdownException, HTIException, ConnectionException{
       
    52 		ScreenCaptureRequest request = new ScreenCaptureRequest(imgMimeType, colorDepth, timeout);
       
    53 		RequestResult result = RequestQueueManager.getInstance().submit(request, printUtility);
       
    54 		return result.getByteData();
       
    55 	}
       
    56 	
       
    57 	/* (non-Javadoc)
       
    58 	 * @see com.nokia.s60tools.hticonnection.services.IScreenCaptureService#getScreenMode(long)
       
    59 	 */
       
    60 	public HTIScreenMode getScreenMode(long timeout) 
       
    61 								throws ServiceShutdownException, HTIException, ConnectionException{
       
    62 		GetScreenModeRequest request = new GetScreenModeRequest(timeout);
       
    63 		RequestResult result = RequestQueueManager.getInstance().submit(request, printUtility);
       
    64 		return result.getScreenMode();
       
    65 	}
       
    66 }