From e3823d8ba0133358535540f59574d125a4240b95 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Wed, 18 Apr 2018 22:34:52 +0200 Subject: Remove previous attempts --- .settings/org.eclipse.ltk.core.refactoring.prefs | 3 - .settings/org.eclipse.wst.validation.prefs | 6 - archiveIMAP.pl | 144 ----------------------- expireIMAP.pl | 35 ------ listFolders.pl | 23 ---- playWithImap.pl | 61 ---------- 6 files changed, 272 deletions(-) delete mode 100644 .settings/org.eclipse.ltk.core.refactoring.prefs delete mode 100644 .settings/org.eclipse.wst.validation.prefs delete mode 100644 archiveIMAP.pl delete mode 100644 expireIMAP.pl delete mode 100644 listFolders.pl delete mode 100644 playWithImap.pl diff --git a/.settings/org.eclipse.ltk.core.refactoring.prefs b/.settings/org.eclipse.ltk.core.refactoring.prefs deleted file mode 100644 index 6f5b144..0000000 --- a/.settings/org.eclipse.ltk.core.refactoring.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun Sep 28 22:23:36 CEST 2008 -eclipse.preferences.version=1 -org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs deleted file mode 100644 index 7df220c..0000000 --- a/.settings/org.eclipse.wst.validation.prefs +++ /dev/null @@ -1,6 +0,0 @@ -#Sun Sep 28 22:23:37 CEST 2008 -DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator\=org.eclipse.wst.wsdl.validation.internal.eclipse.Validator; -USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator; -USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator; -USER_PREFERENCE=overrideGlobalPreferencesfalse -eclipse.preferences.version=1 diff --git a/archiveIMAP.pl b/archiveIMAP.pl deleted file mode 100644 index a1833de..0000000 --- a/archiveIMAP.pl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use Mail::IMAPClient; -use IO::Socket::SSL; -use Data::Dumper; -use DateTime; -use DateTime::Format::Strptime; -use Config::IniFiles; - -# possible values are currently -- zimbra, localhost, pobox -my $account = "localhost"; - -# How many months before today the cut date should be? -my $howManyMonths = 3; -my $debug = 0; - -# get configuration for the account -my $conf = Config::IniFiles->new( -file => "/home/matej/.bugzillarc"); -die "No configuration for account $account" unless $conf->SectionExists($account); -my $hostname = $conf->val($account,'host'); -my $login = $conf->val($account,'name'); -my $password = $conf->val($account,'password'); -my $ssl= $conf->val($account,'ssl'); - -sub getTargetFolder { - my $source = shift; - my $year = shift; - - $source =~ s/^\/*(.*)\/*$/$1/; - return "/INBOX/Archiv/" . $year . '/' . $source; -} - -# makes sure that the folder including its parents -# RFC2060 says in 6.3.3 that server SHOULD create -# parents, so just to be sure if it doesn't. -sub assureFolder { - my $imaphandle = shift; - my $fullfoldername = shift; - my $sep = $imap->separator($fullfoldername); - - if ($imaphandle->exists($fullfoldername)) { - return 1; - } - my $parentpath = join ($sep, - (split /$sep/,$fullfoldername)[0,-1] - ); - assureFolder($imaphandle,$parentpath); - $imaphandle->create($fullfoldername) or - die "Unable to create folder $fullfoldername"; -} - -our $Strp = new DateTime::Format::Strptime( - pattern => '%a, %d %b %Y %H:%M:%S %z' -); -our $StrpNoTZ = new DateTime::Format::Strptime( - pattern => '%a, %d %b %Y %H:%M:%S' -); - -sub getMessageYear { - my $msgStr = shift; - my $msgDt = $Strp->parse_datetime($msgStr); - - if (!$msgDt) { - $msgDt = $StrpNoTZ->parse_datetime($msgStr); - } - if (!$msgDt) { - print "Date EMPTY.\n"; - return ""; # TODO: message without Date: - # not sure what to do about it - # Currently just do nothing and - # return empty string. - } - my $year = $msgDt->year; - if ($debug) { - print "\$msgStr = $msgStr, \$msgDt = $msgDt, year = $year\n"; - } - - return $year; -} - -my $imap = Mail::IMAPClient->new(); -if ($ssl) { - my $sslSocket=IO::Socket::SSL->new("$hostname:imaps"); - die ("Error connecting - $@") unless defined $sslSocket; - $sslSocket->autoflush(1); - - $imap = Mail::IMAPClient->new( - Server => $hostname, - Socket => $sslSocket, - User => $login, - Debug => $debug, - Password => $password, - UID => 1 - ) or die "Cannot connect to localhost as matej: $@"; -} else { - $imap = Mail::IMAPClient->new( - Server => $hostname, - User => $login, - Debug => $debug, - Password => $password, - UID => 1 - ) or die "Cannot connect to localhost as matej: $@"; -} - -my $cutDate = DateTime->now(); -$cutDate->add( months => -$howManyMonths ); - -my @sourceFolders = grep(!/^INBOX\/Archiv/,$imap->folders()); -my %targetedMessages; -my ($msgYear,$msgDateStr,$targetFolder); - -foreach my $folder (@sourceFolders) { - $imap->select($folder); - die "Cannot select folder $folder\n" if $@; - my @msgsProc = $imap->search(" UNDELETED BEFORE " . $cutDate->strftime("%d-%b-%Y")); - if ($#msgsProc > 0) { - print "Move $#msgsProc in $folder.\n"; - foreach my $msg (@msgsProc) { - $msgYear = getMessageYear($imap->date($msg)); - if ($msgYear !~ /^\s*$/) { - $targetFolder = getTargetFolder($folder,$msgYear); - if ($debug) { - print "Move message $msg from the folder $folder to $targetFolder.\n"; - } - push ( @{ $targetedMessages{$folder} } , $msg); - } - } - } - foreach my $tFolder (keys %targetedMessages) { - if (!($imap->exists($tFolder))) { - # Not sure how would following deal with non-existent - # parent folder, so rather recursively create - # parents. - # - #$imap->create($tFolder) - # or die "Could not create $tFolder: $@\n"; - assureFolder($imap,$tFolder); - } - $imap->move($tFolder,$targetedMessages{$tFolder}); - } -} -$imap->close(); \ No newline at end of file diff --git a/expireIMAP.pl b/expireIMAP.pl deleted file mode 100644 index 5f00651..0000000 --- a/expireIMAP.pl +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use Mail::IMAPClient; -use Data::Dumper; -use DateTime; - -my $hostname = "localhost"; -my $login = "matej"; -my $passwd = "lubdkc"; - -die "Just one name of the folder, please." unless $#ARGV == 0; - -# How many months before today the cut date should be? -my $howManyMonths = 3; -my $lengthOfScreen = 65; - -my $imap = Mail::IMAPClient->new(); -$imap = Mail::IMAPClient->new( - Server => $hostname, - User => $login, - Password => $passwd, - UID => 1 -) or die "Cannot connect to localhost as matej: $@"; - -my $cutDate = DateTime->now(); -$cutDate->add( months => -$howManyMonths ); - -# Do the stuff! -$imap->select($ARGV[0]); -my @msgsProc = $imap->search(" UNDELETED BEFORE " . $cutDate->strftime("%d-%b-%Y")); -print "\$#msgsProc = $#msgsProc\n"; -$imap->delete_message(@msgsProc) or die "Cannot delete $#msgsProc messages."; -$imap->close(); \ No newline at end of file diff --git a/listFolders.pl b/listFolders.pl deleted file mode 100644 index 5be4bc6..0000000 --- a/listFolders.pl +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use Mail::IMAPClient; -use Data::Dumper; - -my $msg; -my $hostname = "localhost"; -my $login = "matej"; -my $passwd = "lubdkc"; - -my $imap = Mail::IMAPClient->new(); -$imap = Mail::IMAPClient->new( - Server => $hostname, - User => $login, - Password => $passwd, - UID => 1 -) or die "Cannot connect to localhost as matej: $@"; - -print "\n===============================\n"; -my @folders = $imap->folders; -print join("\n",@folders),"\n"; \ No newline at end of file diff --git a/playWithImap.pl b/playWithImap.pl deleted file mode 100644 index de397ca..0000000 --- a/playWithImap.pl +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use Mail::IMAPClient; -use Data::Dumper; - -my $msg; - -my $imap = Mail::IMAPClient->new(); -$imap = Mail::IMAPClient->new( - Server => "localhost", - User => "matej", - Password => "lubdkc", - UID => 1 -) or die "Cannot connect to localhost as matej: $@"; - -$imap->select('INBOX'); -my $hash = $imap->fetch_hash("RFC822.SIZE","INTERNALDATE","FLAGS","ENVELOPE"); -#print Data::Dumper->Dumpxs([$hash],['$hash']); - -#print "\n===============================\n"; -my @folders = $imap->folders; -#print join("\n",@folders),".\n"; - -#print "\n===============================\n"; -# or s/folders/subscribed/ -@folders = $imap->folders("INBOX" . $imap->separator . "Pratele" . $imap->separator); -print join("\n",@folders),".\n"; - -print "\n===============================\n"; -my $msgID; -my $headers; -foreach $msg (keys(%$hash)) { - $msgID = $imap->get_header($msg,"Message-Id"); - print "\$msg ID = $msg\nMESSAGE-ID = $msgID\n"; - $headers = $imap->parse_headers($msg,"Date","Received","Subject","To"); - print "Headers = " . Data::Dumper->Dumpxs([$headers],['$headers']) . "\n"; -} - -## Get a list of messages in the current folder: -#my @msgs = $imap->messages or die "Could not messages: $@\n"; -## Get a reference to an array of messages in the current folder: -#my $msgs = $imap->messages or die "Could not messages: $@\n"; - -#use Mail::IMAPClient; -# my $imap = Mail::IMAPClient->new( Server => $imaphost, -# User => $login, -# Password=> $pass, -# Uid => 1, # optional -# ); -# -# $imap->select("World Domination"); -# # get the flags for every message in my 'World Domination' folder -# $flaghash = $imap->flags( scalar($imap->search("ALL"))) ; -# -# # pump through sorted hash keys to print results: -# for my $k (sort { $flaghash->{$a} <=> $flaghash->{$b} } keys %$flaghash) { -# # print: Message 1: \Flag1, \Flag2, \Flag3 -# print "Message $k:\t",join(", ",@{$flaghash->{$k}}),"\n"; -# } -- cgit