<commit_before>/**
 * intrabuild
 * (c) 2002-2008 siteartwork.de/MindPatterns
 * <EMAIL>
 *
 * $Author$
 * $Id$
 * $Date$ 
 * $Revision$
 * $LastChangedDate$
 * $LastChangedBy$
 * $URL$ 
 */
 
Ext.namespace('de.intrabuild.groupware.email');

/**
 * The Letterman is a singleton that's responsible for checking for new emails
 * in a given interval. It checks for new emails and delivers the data to the
 * registered listeners. After the Letterman has checked for new mails, it's store
 * will be wiped to make room for new data.
 *
 * If you want to receive messages from this component, you can subscribe to the
 * Ext.ux.util.MessageBus and listen for the following messages:
 * <ul>
 * <li><strong>de.intrabuild.groupware.email.Letterman.beforeload</strong> - sent
 * before this component's store sends a request to the server to receive new messages.
 * The subscriber is passed the following parameters: 
 *     <ul>
 *      <li>subject - the subject of the message</li>
 *      <li>message - an empty object</li>
 *     </ul>
 * </li>
 * <li><strong>de.intrabuild.groupware.email.Letterman.loadexcepion</strong> - sent when
 * a request made by this component's store resulted in a failure.
 * The subscriber is passed the following parameters: 
 *     <ul>
 *      <li>subject - the subject of the message</li>
 *      <li>message - an empty object</li>
 *     </ul>
 * </li>
 * <li><strong>de.intrabuild.groupware.email.Letterman.load</strong> - sent when a request made
 * by this component's store resulted in a successfull response. 
 * The subscriber is passed the following parameters: 
 *     <ul>
 *      <li>subject - the subject of the message</li>
 *      <li>message - an object containing details about the message, with the follwing properties:
 *        <ul>
 *         <li>total - the total number of new emails as received by the server</li>
 *        </ul>
 *       </li>
 *     </ul>
 * </li>
 * </ul>   
 *
 *
 */
de.intrabuild.groupware.email.Letterman = function(config) {
    
    /**
     * A shorthand for the {@see Ext.ux.util.MessageBus} which is used
     * to publish messages to and receive messages from
     */ 
    var _messageBroadcaster = Ext.ux.util.MessageBus;
    
    /**
     * The store in which new emails will be added. The store is wiped upon
     * each new call to load.
     */
    var store = new Ext.data.Store({
        autoLoad    : false,
        remoteSort  : true,
        reader      : new Ext.data.JsonReader({
                          root            : 'items',
                          totalProperty   : 'totalCount',
                          successProperty : 'success',
                          id              : 'id'
                      }, 
                      de.intrabuild.groupware.email.EmailItemRecord
                      ),
        sortInfo   : {field: 'date', direction: 'ASC'},      
        proxy      : new Ext.data.HttpProxy({
            url      : '/groupware/email/fetch.emails/format/json',
            timeout  : 20*60*1000
        })
    });
    
    store.loadRecords = function(o, options, success)
	{
		this.lastLoadingDate = (new Date()).getTime(); 
		
		Ext.data.Store.prototype.loadRecords.call(this, o, options, success);
	};
	
	
    /**
     * The interval in which the letterman should check for new mails, in minutes.
     * @param {Number}
     */
    var interval = 5;
    
    /**
     * The task of the letterman.
     */
    var task = null;
    
    /**
     * The TaskRunner.
     * @param {Ext.util.TaskRunner}
     */
    var letterman = null;
    
    /**
     * Propert to check if the Lettermans run method has been called for the 
     * first time.
     * Defaults to false.
     */
    var called = false;
    
    /**
     * Overrides proxy's loadResponse to check for error
     *
     */
    var proxyResponse = function(o, success, response)
    { 
        var json = de.intrabuild.util.Json;
    	if (json.isError(response.responseText)) {
    	    de.intrabuild.groupware.email.Letterman.onRequestFailure(this, null, response, null);
    	}	
    		
    	return Ext.data.HttpProxy.prototype.loadResponse.call(this, o, success, response);
    
    };
    
	/**
	 * @param {de.intrabuild.groupware.email.AccountStore} 
	 * Shorthand for the store with the configured email accounts.
	 */
	var _accountStore = de.intrabuild.util.Registry.get('de.intrabuild.groupware.email.AccountStore');
	
    /**
     * Listener for the store's beforeload event.
     * Will check if any account is currently configured. If none is found,
     * the request to the server will be cancelled.
     * 
     */
	var _onBeforeLoad = function()
	{
		if (_accountStore.getRange().length == 0) {<commit_msg> - fixed: could not send requests for new emails to the server since the AccountStore was still looked up in the registry; updated source accordingly<commit_after>/**
 * intrabuild
 * (c) 2002-2008 siteartwork.de/MindPatterns
 * <EMAIL>
 *
 * $Author$
 * $Id$
 * $Date$ 
 * $Revision$
 * $LastChangedDate$
 * $LastChangedBy$
 * $URL$ 
 */
 
Ext.namespace('de.intrabuild.groupware.email');

/**
 * The Letterman is a singleton that's responsible for checking for new emails
 * in a given interval. It checks for new emails and delivers the data to the
 * registered listeners. After the Letterman has checked for new mails, it's store
 * will be wiped to make room for new data.
 *
 * If you want to receive messages from this component, you can subscribe to the
 * Ext.ux.util.MessageBus and listen for the following messages:
 * <ul>
 * <li><strong>de.intrabuild.groupware.email.Letterman.beforeload</strong> - sent
 * before this component's store sends a request to the server to receive new messages.
 * The subscriber is passed the following parameters: 
 *     <ul>
 *      <li>subject - the subject of the message</li>
 *      <li>message - an empty object</li>
 *     </ul>
 * </li>
 * <li><strong>de.intrabuild.groupware.email.Letterman.loadexcepion</strong> - sent when
 * a request made by this component's store resulted in a failure.
 * The subscriber is passed the following parameters: 
 *     <ul>
 *      <li>subject - the subject of the message</li>
 *      <li>message - an empty object</li>
 *     </ul>
 * </li>
 * <li><strong>de.intrabuild.groupware.email.Letterman.load</strong> - sent when a request made
 * by this component's store resulted in a successfull response. 
 * The subscriber is passed the following parameters: 
 *     <ul>
 *      <li>subject - the subject of the message</li>
 *      <li>message - an object containing details about the message, with the follwing properties:
 *        <ul>
 *         <li>total - the total number of new emails as received by the server</li>
 *        </ul>
 *       </li>
 *     </ul>
 * </li>
 * </ul>   
 *
 *
 */
de.intrabuild.groupware.email.Letterman = function(config) {
    
    /**
     * A shorthand for the {@see Ext.ux.util.MessageBus} which is used
     * to publish messages to and receive messages from
     */ 
    var _messageBroadcaster = Ext.ux.util.MessageBus;
    
    /**
     * The store in which new emails will be added. The store is wiped upon
     * each new call to load.
     */
    var store = new Ext.data.Store({
        autoLoad    : false,
        remoteSort  : true,
        reader      : new Ext.data.JsonReader({
                          root            : 'items',
                          totalProperty   : 'totalCount',
                          successProperty : 'success',
                          id              : 'id'
                      }, 
                      de.intrabuild.groupware.email.EmailItemRecord
                      ),
        sortInfo   : {field: 'date', direction: 'ASC'},      
        proxy      : new Ext.data.HttpProxy({
            url      : '/groupware/email/fetch.emails/format/json',
            timeout  : 20*60*1000
        })
    });
    
    store.loadRecords = function(o, options, success)
	{
		this.lastLoadingDate = (new Date()).getTime(); 
		
		Ext.data.Store.prototype.loadRecords.call(this, o, options, success);
	};
	
	
    /**
     * The interval in which the letterman should check for new mails, in minutes.
     * @param {Number}
     */
    var interval = 5;
    
    /**
     * The task of the letterman.
     */
    var task = null;
    
    /**
     * The TaskRunner.
     * @param {Ext.util.TaskRunner}
     */
    var letterman = null;
    
    /**
     * Propert to check if the Lettermans run method has been called for the 
     * first time.
     * Defaults to false.
     */
    var called = false;
    
    /**
     * Overrides proxy's loadResponse to check for error
     *
     */
    var proxyResponse = function(o, success, response)
    { 
        var json = de.intrabuild.util.Json;
    	if (json.isError(response.responseText)) {
    	    de.intrabuild.groupware.email.Letterman.onRequestFailure(this, null, response, null);
    	}	
    		
    	return Ext.data.HttpProxy.prototype.loadResponse.call(this, o, success, response);
    
    };
    
	/**
	 * @param {de.intrabuild.groupware.email.AccountStore} 
	 * Shorthand for the store with the configured email accounts.
	 */
	var _accountStore = de.intrabuild.groupware.email.AccountStore.getInstance();
	
    /**
     * Listener for the store's beforeload event.
     * Will check if any account is currently configured. If none is found,
     * the request to the server will be cancelled.
     * 
     */
	var _onBeforeLoad = function()
	{
		if (_accountStore.getRange().length == 0) {
{'fraction_non_alphanumeric': 0.10951431868247141, 'fraction_numerical': 0.0037763558166369455, 'mean_word_length': 2.18436873747495, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6714165', 'n_tokens_mistral': 2878, 'n_tokens_neox': 2745, 'n_words': 870}