/*
 * HOMER 5 UI (Xenophon)
 *
 * Copyright (C) 2011-2015 Alexandr Dubovikov <alexandr.dubovikov@gmail.com>
 * Copyright (C) 2011-2015 Lorenzo Mangani <lorenzo.mangani@gmail.com> QXIP B.V.
 * License AGPL-3.0 http://opensource.org/licenses/AGPL-3.0
 *
*/

(function (angular, homer) {
    'use strict';

    angular.module('homerCore', []).factory('search', [
        '$q',
	'$http',
        function ($q, $http) {
                                                                                                                
                
                var searchMessageById = function (data) {
                
                        var defer = $q.defer();
                                                            
                        $http.post('/api/search/share/message', data).then(
        			/* good response */
	                    function (results) {
	        		    if(results.data.auth == "false") {				
                                        defer.reject('user not authorized');
	            		    }	
		        	    else {
                                        defer.resolve(results.data.data);                                                                        
                                    }
                            },
        			/* bad response */
	        		function (results) {
		        		defer.reject('bad response combination');
                                }
        		 );   
		    
        		return defer.promise;		                                                 
                };
                
                var searchTransactionById = function (data) {
                
                        var defer = $q.defer();
                                                            
                        $http.post('/api/search/share/transaction', data).then(
        			/* good response */
	                    function (results) {
	        		    if(results.data.auth == "false") {				
                                        defer.reject('user not authorized');
	            		    }	
		        	    else {
                                        defer.resolve(results.data.data);                                                                        
                                    }
                            },
        			/* bad response */
	        		function (results) {
		        		defer.reject('bad response combination');
                                }
        		 );   
		    
        		return defer.promise;		                                                 
                };
                
                var makePcapTextforTransactionById = function (data, text) {
                
                        var defer = $q.defer();
                        
                        var url = '/api/search/share/export/';
                        
                        if(text == true) url+= "text";
                        else url+="pcap";
                                                            
                        $http.post(url, data, {responseType:'arraybuffer'}).then(
        			/* good response */
	                    function (results) {
	        		    if(results.data.auth == "false") {				
                                        defer.reject('user not authorized');
	            		    }	
		        	    else {
                                        defer.resolve(results.data);                                                                        
                                    }
                            },
        			/* bad response */
	        		function (results) {
		        		defer.reject('bad response combination');
                                }
        		 );   
		    
        		return defer.promise;		                                                 
                };
                
                return {
                   searchMessageById: searchMessageById,
                   searchTransactionById: searchTransactionById,
                   makePcapTextforTransactionById: makePcapTextforTransactionById
                };
          }
    ]);
}(angular, homer));

@@ -3816,32 +3816,2954 @@
                %0A
+                var searchRTCPReportById = function (data) %7B%0A%0A                        var defer = $q.defer();%0A%0A                        $http.post('/api/report/share/rtcp', data).then(%0A                                /* good response */%0A                            function (results) %7B%0A                                    if(results.data.auth == %22false%22) %7B%0A                                        defer.reject('user not authorized');%0A                                    %7D%0A                                    else %7B%0A                                        defer.resolve(results.data.data);%0A                                    %7D%0A                            %7D,%0A                                /* bad response */%0A                                function (results) %7B%0A                                        defer.reject('bad response combination');%0A                                %7D%0A                         );%0A%0A                        return defer.promise;%0A                %7D;%0A%0A                var searchLogReportById = function (data) %7B%0A%0A                        var defer = $q.defer();%0A%0A                        $http.post('/api/report/share/log', data).then(%0A                                /* good response */%0A                            function (results) %7B%0A                                    if(results.data.auth == %22false%22) %7B%0A                                        defer.reject('user not authorized');%0A                                    %7D%0A                                    else %7B%0A                                        defer.resolve(results.data.data);%0A                                    %7D%0A                            %7D,%0A                                /* bad response */%0A                                function (results) %7B%0A                                        defer.reject('bad response combination');%0A                                %7D%0A                         );%0A%0A                        return defer.promise;%0A                %7D;%0A%09%09%0A%09%09 var searchQualityReportById = function (type, data) %7B%0A%0A                        var defer = $q.defer();%0A%0A                        $http.post('/api/report/share/quality/'+type, data).then(%0A                                /* good response */%0A                            function (results) %7B%0A                                    if(results.data.auth == %22false%22) %7B%0A                                        defer.reject('user not authorized');%0A                                    %7D%0A                                    else %7B%0A                                        defer.resolve(results.data.data);%0A                                    %7D%0A                            %7D,%0A                                /* bad response */%0A                                function (results) %7B%0A                                        defer.reject('bad response combination');%0A                                %7D%0A                         );%0A%0A                        return defer.promise;%0A                %7D;%0A%0A%0A
                 
@@ -6974,16 +6974,209 @@
 tionById
+,%0A                   searchQualityReportById: searchQualityReportById,%0A                   searchLogReportById: searchLogReportById,%0A                   searchRTCPReportById: searchRTCPReportById
 %0A       
@@ -7179,32 +7179,33 @@
              %7D;%0A
+%0A
           %7D%0A    

Update search.js