% cb_timerClearPassord callback method which disconnects the connection and clears the password
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% description: cb_timerClearPassord callback method which disconnects the
%              connection and clears the password
%
% version:     $Id: cb_timerClearPassord.m,v 1.6 2010/08/16 18:04:36 ingo Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = cb_timerClearPassord(varargin)
  
  prefs = getappdata(0, 'LTPDApreferences');
  
  rm    = LTPDARepositoryManager();
  conns = rm.manager.getConnections();
  
  if ~isempty(conns)
    
    for ii=1:conns.size
      conn = conns.get(ii-1);
      
      % Clear the password only if the connection is not locked
      if ~conn.isLocked
        if conn.isConnected
          conn.closeConnection();
        end
        
        if (conn.agePassword > double(prefs.getRepoPrefs.getExpiry))
          conn.setPassword('');
        end
      end
      
    end
    
  end
  if ~isempty(rm.gui)
    rm.gui.reloadConnectionTable();
  end
end
