Index: openacs-4/packages/mail-tracking/mail-tracking.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/mail-tracking.info,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/mail-tracking/mail-tracking.info	24 Oct 2005 17:42:02 -0000	1.4
+++ openacs-4/packages/mail-tracking/mail-tracking.info	17 Mar 2006 10:06:45 -0000	1.5
@@ -8,7 +8,7 @@
     <singleton-p>t</singleton-p>
     <auto-mount>tracking</auto-mount>
 
-    <version name="0.3b3" url="http://openacs.org/repository/download/apm/mail-tracking-0.3b3.apm">
+    <version name="0.4" url="http://openacs.org/repository/download/apm/mail-tracking-0.4.apm">
         <owner url="mailto:mazloumi@uni-mannheim.de">Nima Mazloumi</owner>
         <summary>Mail tracking package. Records all messages send out by acs-mail-lite.</summary>
         <release-date>2005-10-24</release-date>
@@ -18,7 +18,7 @@
 </description>
         <maturity>0</maturity>
 
-        <provides url="mail-tracking" version="0.3b3"/>
+        <provides url="mail-tracking" version="0.4"/>
         <requires url="acs-mail-lite" version="1.0b2"/>
 
         <callbacks>
Index: openacs-4/packages/mail-tracking/lib/messages.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/lib/messages.tcl,v
diff -u -r1.25 -r1.26
--- openacs-4/packages/mail-tracking/lib/messages.tcl	19 Dec 2005 23:03:57 -0000	1.25
+++ openacs-4/packages/mail-tracking/lib/messages.tcl	17 Mar 2006 10:06:45 -0000	1.26
@@ -245,6 +245,26 @@
     }
 
 
+    set count 0
+    while {[regexp {^(.*?)\t?=\?[^\?]+\?Q\?(.*?)\?=\n?(.*?)$} $subject match before quoted after] && $count < 5} {
+	incr count
+	set result ""
+	for { set i 0 } { $i < [string length $quoted] } { incr i } {
+	    set current [string index $quoted $i]
+	    if {$current == "="} {
+		incr i
+		set high [string index $quoted $i]
+		incr i
+		set low [string index $quoted $i]
+		set current [binary format H2 "$high$low"]
+	    } elseif {[string eq $current "_"]} {
+		set current " "
+	    }
+	    append result $current
+	}
+	set subject "$before$result$after"
+    }
+
     set files [list]
     # We get the related files for all the object_types
     set content_types [list content_revision content_item file_storage_object image]
Index: openacs-4/packages/mail-tracking/lib/messages.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/lib/messages.xql,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/mail-tracking/lib/messages.xql	21 Oct 2005 22:12:54 -0000	1.6
+++ openacs-4/packages/mail-tracking/lib/messages.xql	17 Mar 2006 10:06:45 -0000	1.7
@@ -17,8 +17,7 @@
 		log_id
         from 
 		acs_mail_log
-	where 
-		message_id <> 0
+	where 1=1
 		$recipient_where_clause
 		[template::list::page_where_clause -and -name messages]		
         	[template::list::filter_where_clauses -and -name messages]
@@ -29,8 +28,8 @@
     <fullquery name="messages_pagination">
         <querytext>
          select log_id
-        from acs_mail_log	
-	where message_id <> 0	
+        from acs_mail_log
+	where 1=1	
 	$recipient_where_clause 
         [template::list::filter_where_clauses -and -name messages]
         [template::list::orderby_clause -orderby -name messages]
Index: openacs-4/packages/mail-tracking/sql/postgresql/mail-tracking-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/sql/postgresql/mail-tracking-create.sql,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/mail-tracking/sql/postgresql/mail-tracking-create.sql	19 Dec 2005 22:52:19 -0000	1.5
+++ openacs-4/packages/mail-tracking/sql/postgresql/mail-tracking-create.sql	17 Mar 2006 10:06:45 -0000	1.6
@@ -34,9 +34,15 @@
 	package_id		integer,
 	subject			varchar(1024),
 	body			text,
+	-- List of CC E-Mail addresses, seperated by "," as passed in from acs-mail-lite::send prozedures
+	cc			varchar(4000),
 	sent_date		timestamp);
 
+create index acs_mail_log_object_idx on acs_mail_log(object_id);
+create index acs_mail_log_recipient_idx on acs_mail_log(recipient_id);
+create index acs_mail_log_sender_idx on acs_mail_log(sender_id);
 
+
 -- create the content type
 select acs_object_type__create_type (
    'mail_log',              -- content_type
@@ -51,7 +57,7 @@
    NULL                           -- name_method
 );
 
-create or replace function acs_mail_log__new (integer,varchar, integer, integer, integer, varchar, varchar,integer,varchar,integer,integer)
+create or replace function acs_mail_log__new (integer,varchar, integer, integer, integer, varchar, varchar,integer,varchar,integer,integer,varchar)
 returns integer as '
 declare	
 	p_log_id alias for $1;
@@ -65,6 +71,7 @@
         p_creation_ip alias for $9;
         p_context_id alias for $10;
 	p_object_id alias for $11;
+	p_cc alias for $11;
 	v_log_id acs_mail_log.log_id%TYPE;
 begin
 	v_log_id := acs_object__new (
@@ -73,9 +80,9 @@
 	);
 
 	insert into acs_mail_log
-		(log_id, message_id, recipient_id, sender_id, package_id, subject, body, sent_date, object_id)
+		(log_id, message_id, recipient_id, sender_id, package_id, subject, body, sent_date, object_id, cc)
 	values
-		(v_log_id, p_message_id, p_recipient_id, p_sender_id, p_package_id, p_subject, p_body, now(), p_object_id);
+		(v_log_id, p_message_id, p_recipient_id, p_sender_id, p_package_id, p_subject, p_body, now(), p_object_id, p_cc);
 
 	return v_log_id;
 
Index: openacs-4/packages/mail-tracking/tcl/mail-tracking-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/tcl/mail-tracking-callback-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/mail-tracking/tcl/mail-tracking-callback-procs.tcl	24 Oct 2005 17:41:10 -0000	1.3
+++ openacs-4/packages/mail-tracking/tcl/mail-tracking-callback-procs.tcl	17 Mar 2006 10:06:46 -0000	1.4
@@ -19,20 +19,26 @@
     {-subject ""}
     {-object_id ""}
     {-file_ids ""}
+    {-cc ""}
 } {
     create a new entry in the mail tracking table
 } {
     
+    if {![exists_and_not_null cc]} {
+	set cc ""
+    }
     # We need to put lindex here since the value from
     # the swithc converts this "element element" to this
     # "{element element}"
-    set file_ids [lindex $file_ids 0]
+    # set file_ids [lindex $file_ids 0]
+    set file_ids [string trim $file_ids "{}"]
     set log_id [mail_tracking::new -package_id $package_id \
 		    -sender_id $from_party_id \
 		    -recipient_id $to_party_id \
 		    -body $body \
 		    -message_id $message_id \
 		    -subject $subject \
+		    -cc $cc \
 		    -object_id $object_id]
 
     foreach file_id $file_ids {
Index: openacs-4/packages/mail-tracking/tcl/mail-tracking-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/tcl/mail-tracking-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/mail-tracking/tcl/mail-tracking-procs.tcl	15 Jun 2005 15:41:12 -0000	1.2
+++ openacs-4/packages/mail-tracking/tcl/mail-tracking-procs.tcl	17 Mar 2006 10:06:46 -0000	1.3
@@ -33,8 +33,10 @@
     {-subject ""}
     {-object_id ""}
     {-context_id ""}
+    {-cc ""}
 } {
     Insert new log entry
+    @param cc CC E-Mail Address as recieved from the send procedures
 } {
     set creation_ip "127.0.0.1"
     return [db_exec_plsql insert_log_entry {select acs_mail_log__new (
@@ -48,7 +50,8 @@
 								     :sender_id,
 								     :creation_ip,
 								     :context_id,
-								     :object_id
+								     :object_id,
+								     :cc
 								     )}]
     
 }	       
Index: openacs-4/packages/mail-tracking/www/one-message.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/www/one-message.adp,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/mail-tracking/www/one-message.adp	20 Dec 2005 14:57:20 -0000	1.3
+++ openacs-4/packages/mail-tracking/www/one-message.adp	17 Mar 2006 10:06:46 -0000	1.4
@@ -4,12 +4,16 @@
 
 <a href="@return_url;noquote@">#mail-tracking.Go_Back#</a>
 <br><br>
-<pre style="background-color: #eee; padding: .5em;">
-#mail-tracking.Sender#:      @sender;noquote@
-#mail-tracking.Recipient#:   @recipient;noquote@
-#mail-tracking.Subject#:     @subject;noquote@
-#mail-tracking.Attachments#: @download_files;noquote@
-#mail-tracking.MessageID#: @message_id;noquote@
-</pre>
-
+<div style="background-color: #eee; padding: .5em;">
+<table>
+<tr><td>
+#mail-tracking.Sender#:</td><td>@sender;noquote@</tr><td>
+#mail-tracking.Recipient#:</td><td>@recipient;noquote@</tr><td>
+#mail-tracking.CC#:</td><td>@cc;noquote@</tr><td>
+#mail-tracking.Subject#:</td><td>@subject;noquote@</tr><td>
+#mail-tracking.Attachments#:</td><td>@download_files;noquote@</tr><td>
+#mail-tracking.MessageID#:</td><td>@message_id;noquote@</tr>
+</table>
+</div>
+<p>
 @body;noquote@
Index: openacs-4/packages/mail-tracking/www/one-message.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/www/one-message.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/mail-tracking/www/one-message.tcl	19 Dec 2005 22:52:19 -0000	1.6
+++ openacs-4/packages/mail-tracking/www/one-message.tcl	17 Mar 2006 10:06:46 -0000	1.7
@@ -29,6 +29,10 @@
 # Get the information of the message
 db_1row get_message_info { }
 
+if {![exists_and_not_null cc]} {
+    set cc ""
+}
+
 if { [catch { set sender [person::name -person_id $sender_id] } errorMsg] } {
     # We will try to see if it's a contact and has an email. This will break
     # if the contacts package is not installed so this is why we need to put