/*******************************************************************************
 * Copyright (c) 2016 Ericsson
 *
 * All rights reserved. This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.cdt.example.framespy;

import java.util.Hashtable;

import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.service.AbstractDsfService;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.osgi.framework.BundleContext;

public class FrameSpyService extends AbstractDsfService {

	public FrameSpyService(DsfSession session) {
		super(session);
	}

	@Override
	protected BundleContext getBundleContext() {
		return Activator.getBundleContext();
	}
	
	@Override
	public void initialize(RequestMonitor rm) {
		super.initialize(
			new RequestMonitor(getExecutor(), rm) {
				@Override
				protected void handleSuccess() {
					// Register when the service is ready to be called
					register(new String[]{FrameSpyService.class.getName()}, new Hashtable<String,String>());
					rm.done();
				}
			});
	}
	
	@Override
	public void shutdown(RequestMonitor rm) {
		// Unregister first, so that no one calls us anymore
		unregister();
		super.shutdown(rm);
	}
}

@@ -496,24 +496,144 @@
 ava.
-util.Hashtable;%0A
+text.SimpleDateFormat;%0Aimport java.util.Calendar;%0Aimport java.util.Hashtable;%0A%0Aimport org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
 %0Aimp
@@ -1559,10 +1559,523 @@
 rm);%0A%09%7D%0A
+%09%0A%09public String getLocalTimeOfDayString() %7B%0A%09%09return new SimpleDateFormat(%22HH:mm:ss%22).format(Calendar.getInstance().getTime());%0A%09%7D%0A%09%0A%09// The asynchronous method below is more versatile because it could%0A%09// be used to go ask GDB the time of day on the target.%0A%09// Since sending message to GDB is considered long, we must use an%0A%09// asynchronous method.%0A%09public void getTargetTimeOfDayString(DataRequestMonitor%3CString%3E rm) %7B%0A%09%09rm.done(new SimpleDateFormat(%22HH:mm:ss%22).format(Calendar.getInstance().getTime()));%0A%09%7D%0A
 %7D%0A

Implement getTimeOfDayString() method in new service