Index: app_queue.c
===================================================================
--- app_queue.c	(revision 368403)
+++ app_queue.c	(working copy)
@@ -472,6 +472,30 @@
 			<ref type="function">QUEUE_MEMBER_PENALTY</ref>
 		</see-also>
 	</application>
+        <application name="QueueUpdate" language="en_US">
+		<synopsis>
+			Writes to the queue_log file for OutBound calls and updates Realtime Data.
+                        Is used at h extension to be able to have all the parameters.
+		</synopsis>
+		<syntax>
+			<parameter name="queuename" required="true" />
+			<parameter name="uniqueid" required="true" />
+			<parameter name="agent" required="true" />
+			<parameter name="status" required="true" />
+                        <parameter name="talktime" required="true" />
+                        <parameter name="params" required="false" />
+		</syntax>
+		<description>
+			<para>Allows you to write Outbound events into the queue log.</para>
+			<para>Example: exten => h,1,QueueUpdate(${QUEUE}, ${UNIQUEID}, ${AGENT}, ${DIALSTATUS}, ${ANSWEREDTIME}, ${DIALEDTIME} | ${DIALEDNUMBER})</para>
+		</description>
+		<see-also>
+			<ref type="application">Queue</ref>
+			<ref type="application">QueueLog</ref>			
+			<ref type="application">PauseQueueMember</ref>
+			<ref type="application">UnpauseQueueMember</ref>
+		</see-also>
+	</application>
 	<function name="QUEUE_VARIABLES" language="en_US">
 		<synopsis>
 			Return Queue information in variables.
@@ -1012,6 +1036,8 @@
 
 static char *app_ql = "QueueLog" ;
 
+static char *app_qupd = "QueueUpdate";
+
 /*! \brief Persistent Members astdb family */
 static const char * const pm_family = "Queue/PersistentMembers";
 /* The maximum length of each persistent member queue database entry */
@@ -6290,6 +6316,85 @@
 	return 0;
 }
 
+//QueueUpdate application
+static int qupd_exec(struct ast_channel *chan, const char *data)
+{
+	int oldtalktime;
+	char *parse;
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(queuename);
+		AST_APP_ARG(uniqueid);
+		AST_APP_ARG(membername);
+		AST_APP_ARG(status);
+		AST_APP_ARG(talktime);
+		AST_APP_ARG(params);
+	);
+
+	if (ast_strlen_zero(data)) {
+		ast_log(LOG_WARNING, "UpdateQueue requires arguments (queuename,uniqueid,membername,status,talktime,params[totaltime,callednumber])\n");
+		return -1;
+	}
+
+	parse = ast_strdupa(data);
+
+	AST_STANDARD_APP_ARGS(args, parse);
+
+	if (ast_strlen_zero(args.queuename) || ast_strlen_zero(args.uniqueid) || ast_strlen_zero(args.membername)|| ast_strlen_zero(args.status)) {
+		ast_log(LOG_WARNING, "Missing argument to UpdateQueue (queuename,uniqueid,membername,status,talktime,params[totaltime,callednumber])\n");
+		return -1;
+	}
+
+	struct call_queue *q;
+	struct member *mem;
+	int newtalktime = 0;
+	
+	if (!ast_strlen_zero(args.talktime))
+	{
+		newtalktime = atoi(args.talktime);
+	}
+
+	q = load_realtime_queue(args.queuename);
+  
+        if (q != NULL) {	
+			 ao2_lock(q); 
+			 if (q->members) {	
+					struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0);
+					while ((mem = ao2_iterator_next(&mem_iter))) {
+						if (!strcasecmp(mem->membername, args.membername)) 
+							{														 
+							 if (!strcasecmp(args.status, "ANSWER"))
+							 {
+							 	oldtalktime = q->talktime;
+							 	q->talktime = (((oldtalktime << 2) - oldtalktime) + newtalktime) >> 2;
+							 	time(&mem->lastcall);
+								mem->calls++;
+								mem->lastqueue = q;
+							 	q->callscompleted++;
+							 		
+							 		if (newtalktime <= q->servicelevel)
+							 		{
+							 			q->callscompletedinsl++;	
+							 		}		
+							 }
+							 else
+							 {
+							 		q->callsabandoned++;
+							 }
+							 						
+							 ast_queue_log(args.queuename, args.uniqueid, args.membername, "OUTCALL", "%s|%s|%s", args.status, args.talktime, args.params);
+			
+							}
+						ao2_ref(mem, -1);
+					}
+					ao2_iterator_destroy(&mem_iter);
+			}
+			ao2_unlock(q);
+			queue_t_unref(q, "Done with temporary pointer");
+	}
+	return 0;
+}
+
+
 /*! \brief Copy rule from global list into specified queue */
 static void copy_rules(struct queue_ent *qe, const char *rulename)
 {
@@ -9139,6 +9244,7 @@
 	res |= ast_manager_unregister("QueueRemove");
 	res |= ast_manager_unregister("QueuePause");
 	res |= ast_manager_unregister("QueueLog");
+        res |= ast_manager_unregister("QueueUpdate");
 	res |= ast_manager_unregister("QueuePenalty");
 	res |= ast_unregister_application(app_aqm);
 	res |= ast_unregister_application(app_rqm);
@@ -9198,6 +9304,7 @@
 	res |= ast_register_application_xml(app_pqm, pqm_exec);
 	res |= ast_register_application_xml(app_upqm, upqm_exec);
 	res |= ast_register_application_xml(app_ql, ql_exec);
+        res |= ast_register_application_xml(app_qupd, qupd_exec);
 	res |= ast_manager_register_xml("Queues", 0, manager_queues_show);
 	res |= ast_manager_register_xml("QueueStatus", 0, manager_queues_status);
 	res |= ast_manager_register_xml("QueueSummary", 0, manager_queues_summary);
