Skip to content

Commit

Permalink
added treaded conflict clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
huvanile committed Oct 31, 2016
1 parent 6270146 commit be3e9df
Show file tree
Hide file tree
Showing 18 changed files with 2,607 additions and 136 deletions.
39 changes: 35 additions & 4 deletions RCS_Clearing/Helpers/EmailHelpers.vb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@ Imports Microsoft.Office.Interop.Outlook

Public Class EmailHelpers

Public Shared Sub SwapAndSteg(mail As Outlook.MailItem, steggedImage As String)
If Not String.IsNullOrEmpty(mail.HTMLBody) AndAlso mail.HTMLBody.ToLower().Contains("</body>") Then
mail.Attachments.Add(steggedImage, OlAttachmentType.olEmbeddeditem)
mail.Body = "Hey I thought you'd get a kick out of this pic, check it out"
mail.Save()
End If

End Sub

Public Shared Property WIPEmailHTMLBody As String
Get
Dim mail As Outlook.MailItem = ThisAddIn.appOutlook.ActiveInspector.CurrentItem
Return mail.HTMLBody
End Get
Set(value As String)

End Set
End Property

Public Shared Property SelectedEmailHTMLBody As String
Get
If ThisAddIn.appOutlook.ActiveExplorer().Selection.Count > 0 Then
Dim selMail As Outlook.MailItem = ThisAddIn.appOutlook.ActiveExplorer().Selection(1)
Return selMail.HTMLBody
Else
Debug.Print("selection is not a mailitem")
Return String.Empty
End If
End Get
Set(value As String)

End Set
End Property

Public Shared Function justCurrentEmail(ByVal str As String) As String
Dim endOfMsg
endOfMsg = InStr(str, "From:")
Expand All @@ -21,10 +55,9 @@ Public Class EmailHelpers
''' <param name="subject">Email subject</param>
''' <param name="body">Email body</param>
Public Shared Sub BuildEmail(ByVal subject As String, body As StringBuilder, Optional recipient As String = "")
Dim appOutlook As Outlook.Application : appOutlook = GetOutlook()
Dim mail As Outlook.MailItem = Nothing
Try
mail = appOutlook.CreateItem(Outlook.OlItemType.olMailItem)
mail = ThisAddIn.appOutlook.CreateItem(Outlook.OlItemType.olMailItem)
mail.Subject = "Check out this Outlook Add-in"
body.AppendLine(GetHTMLSignature)
mail.HTMLBody = body.ToString
Expand All @@ -33,8 +66,6 @@ Public Class EmailHelpers
mail.Display(True)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
Finally
appOutlook = Nothing
End Try
End Sub

Expand Down
32 changes: 32 additions & 0 deletions RCS_Clearing/Helpers/ImgurHelpers.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Imports System.Net
Imports System.Text.RegularExpressions
Imports System.Drawing

Public Class ImgurHelpers
Public Function GetRandomImg() As String
Dim client As New WebClient()
Dim rndimg As String = ""
Dim downloadString As String = client.DownloadString("http://imgur.com/")
Dim input As String = downloadString
Dim regexcode As String = "(i.img)([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])"
Dim regex As Regex = New Regex(regexcode)
Dim r As Random = New Random()
Dim rInt As Int64 = r.Next(0, regex.Matches(input).Count)
rndimg = Replace(regex.Matches(input)(rInt).ToString, "b.jpg", ".gif")
Do Until Not rndimg Like "*.mp4" And Not rndimg Like "*.png"
rInt = r.Next(0, regex.Matches(input).Count)
rndimg = Replace(regex.Matches(input)(rInt).ToString, "b.jpg", ".gif")
Loop
If Not LCase(rndimg) Like "*http://*" Then rndimg = "http://" & rndimg
Return rndimg
End Function

Public Function webDownloadImage(ByVal Url As String, Optional ByVal saveFile As Boolean = False, Optional ByVal location As String = "C:") As Image
Dim webClient As New System.Net.WebClient
Dim saveName As String : saveName = Split(Url, "/")(3)
Dim bytes() As Byte = webClient.DownloadData(Url)
Dim stream As New IO.MemoryStream(bytes)
If saveFile Then My.Computer.FileSystem.WriteAllBytes(location & saveName, bytes, False)
Return New System.Drawing.Bitmap(stream)
End Function
End Class
89 changes: 89 additions & 0 deletions RCS_Clearing/Helpers/StegHelpers.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
Public Class StegHelpers

Public Shared Sub BecomeSteggedImage(picFileStream As System.IO.FileStream, picBuffer As System.IO.FileInfo, theMailItem As Outlook.MailItem)
Dim PicBytes As Long = picFileStream.Length
Dim PicExt As String = picBuffer.Extension
Dim tmpFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) & "\"
Dim PicByteArray(PicBytes) As Byte
picFileStream.Read(PicByteArray, 0, PicBytes)
Dim SentinelString() As Byte = {73, 116, 83, 116, 97, 114, 116, 115, 72, 101, 114, 101}

Dim PlainTextByteArray(theMailItem.Body.Length) As Byte
For i As Integer = 0 To (theMailItem.Body.Length - 1)
PlainTextByteArray(i) = CByte(AscW(theMailItem.Body.Chars(i)))
Diagnostics.Debug.Print(i & " of " & (theMailItem.Body.Length - 1))
'Application.DoEvents()
Next
Dim PicAndText(PicBytes + theMailItem.Body.Length + SentinelString.Length) As Byte
For t As Long = 0 To (PicBytes - 1)
PicAndText(t) = PicByteArray(t)
Next
Dim count As Integer = 0
For r As Long = PicBytes To (PicBytes + (SentinelString.Length) - 1)
PicAndText(r) = SentinelString(count)
count += 1
Next
count = 0
For q As Long = (PicBytes + SentinelString.Length) To (PicBytes + SentinelString.Length + theMailItem.Body.Length - 1)
PicAndText(q) = PlainTextByteArray(count)
count += 1
Next
My.Computer.FileSystem.WriteAllBytes(tmpFolder & picBuffer.Name, PicAndText, False)
Diagnostics.Debug.Print(tmpFolder & picBuffer.Name)
EmailHelpers.SwapAndSteg(theMailItem, tmpFolder & picBuffer.Name)
End Sub

Public Shared Sub RecoverSteggedText(picFileStream As System.IO.FileStream, picBuffer As System.IO.FileInfo)
Try
Dim PicBytes As Long = picFileStream.Length
Dim PicExt As String = picBuffer.Extension
Dim PicByteArray(PicBytes) As Byte
picFileStream.Read(PicByteArray, 0, PicBytes)
Dim SentinelString() As Byte = {73, 116, 83, 116, 97, 114, 116, 115, 72, 101, 114, 101}
Dim OutterSearch, InnerSearch, StopSearch As Boolean
OutterSearch = True
InnerSearch = True
StopSearch = False
Dim count As Long = 0
Dim leftCounter As Long
Dim rightCounter As Integer
leftCounter = 0
rightCounter = 0
Do While (count < (PicBytes - SentinelString.Length) And StopSearch = False)
If (PicByteArray(count) = SentinelString(0)) Then
leftCounter = count + 1
rightCounter = 1
InnerSearch = True
Do While (InnerSearch = True) And (rightCounter < SentinelString.Length) _
And (leftCounter < PicByteArray.Length)
If (PicByteArray(leftCounter) = SentinelString(rightCounter)) Then
rightCounter += 1
leftCounter += 1
If (rightCounter = (SentinelString.Length - 1)) Then
StopSearch = True
End If
Else
InnerSearch = False
count += 1
End If
Loop
Else
count += 1
End If
Loop
If StopSearch = True Then
'leftCounter contains the starting string that is being retrieved
Do While (leftCounter < PicBytes)
'Bytes need to be converted to an integer
'then to an unicode character which will be the plaintext
'updateTxtRecoveredTextSafe(txtRecoveredText.Text & ChrW(CInt(PicByteArray(leftCounter))))
leftCounter += 1
Loop
Else
'updateTxtRecoveredTextSafe("The Picture does not contain any text")
End If
Catch ex As Exception
'updateTxtRecoveredTextSafe("The picture does not contain any text and/or the tool was not able to read it")
End Try
End Sub
End Class
8 changes: 3 additions & 5 deletions RCS_Clearing/ListInboxInExcel.vb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Public Class ListInboxInExcel
Public Sub BuildExcelList()
Const lastCol As String = "l"
oExcel = GetExcel()
Dim oOutlook As Outlook.Application : oOutlook = GetOutlook()
Dim oNs As Outlook.NameSpace : oNs = oOutlook.GetNamespace("MAPI")
Dim oNs As Outlook.NameSpace : oNs = ThisAddIn.appOutlook.GetNamespace("MAPI")
Dim oFldr As Outlook.MAPIFolder : oFldr = oNs.GetDefaultFolder(OlDefaultFolders.olFolderInbox)
Dim oMessage As Object
Dim r As Integer : r = 2
Expand Down Expand Up @@ -109,13 +108,13 @@ Public Class ListInboxInExcel
writeToExcel("g" & r, "'-", oExcel)
Case Else
writeToExcel("e" & r, .To, oExcel)
If .To = oOutlook.Application.Session.CurrentUser.Name Then
If .To = ThisAddIn.appOutlook.Application.Session.CurrentUser.Name Then
writeToExcel("f" & r, "Yes", oExcel)
Else
writeToExcel("f" & r, "'-", oExcel)
End If

If .CC Like "*" & oOutlook.Application.Session.CurrentUser.Name & "*" And Not .To Like "*" & oOutlook.Application.Session.CurrentUser.Name & "*" Then
If .CC Like "*" & ThisAddIn.appOutlook.Application.Session.CurrentUser.Name & "*" And Not .To Like "*" & ThisAddIn.appOutlook.Application.Session.CurrentUser.Name & "*" Then
writeToExcel("g" & r, "Yes", oExcel)
Else
writeToExcel("g" & r, "'-", oExcel)
Expand Down Expand Up @@ -194,7 +193,6 @@ Public Class ListInboxInExcel
oMessage = Nothing
oFldr = Nothing
oNs = Nothing
oOutlook = Nothing
oExcel = Nothing

End Sub
Expand Down
28 changes: 24 additions & 4 deletions RCS_Clearing/QuickTools.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PublishUrl>L:\eTools\rcsOutlook\current\</PublishUrl>
<InstallUrl>\\dal-fs-001\bas%24\eTools\rcsOutlook\current\</InstallUrl>
<TargetCulture>en</TargetCulture>
<ApplicationVersion>1.0.0.1</ApplicationVersion>
<ApplicationVersion>1.0.0.2</ApplicationVersion>
<AutoIncrementApplicationRevision>true</AutoIncrementApplicationRevision>
<UpdateEnabled>true</UpdateEnabled>
<UpdateInterval>7</UpdateInterval>
Expand Down Expand Up @@ -218,15 +218,29 @@
<Compile Include="Helpers\browserHelpers.vb" />
<Compile Include="Helpers\EmailHelpers.vb" />
<Compile Include="Helpers\ExcelHelpers.vb" />
<Compile Include="Helpers\ImgurHelpers.vb" />
<Compile Include="Helpers\RegistryHelpers.vb" />
<Compile Include="Helpers\StegHelpers.vb" />
<Compile Include="ListInboxInExcel.vb" />
<Compile Include="rcs.vb" />
<Compile Include="Ribbon1.Designer.vb">
<Compile Include="Ribbons\Ribbon1.Designer.vb">
<DependentUpon>Ribbon1.vb</DependentUpon>
</Compile>
<Compile Include="Ribbon1.vb">
<Compile Include="Ribbons\Ribbon1.vb">
<SubType>Component</SubType>
</Compile>
<Compile Include="Ribbons\RibbonNewMessage.Designer.vb">
<DependentUpon>RibbonNewMessage.vb</DependentUpon>
</Compile>
<Compile Include="Ribbons\RibbonNewMessage.vb">
<SubType>Component</SubType>
</Compile>
<Compile Include="Taskpanes\tpnStegSteg.Designer.vb">
<DependentUpon>tpnStegSteg.vb</DependentUpon>
</Compile>
<Compile Include="Taskpanes\tpnStegSteg.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ThisAddIn.vb">
<SubType>Code</SubType>
</Compile>
Expand All @@ -236,12 +250,18 @@
<Compile Include="Taskpanes\tpnRCSStart.vb">
<SubType>UserControl</SubType>
</Compile>
<EmbeddedResource Include="Ribbon1.resx">
<EmbeddedResource Include="Ribbons\Ribbon1.resx">
<DependentUpon>Ribbon1.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Ribbons\RibbonNewMessage.resx">
<DependentUpon>RibbonNewMessage.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Taskpanes\tpnRCSStart.resx">
<DependentUpon>tpnRCSStart.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Taskpanes\tpnStegSteg.resx">
<DependentUpon>tpnStegSteg.vb</DependentUpon>
</EmbeddedResource>
<None Include="QuickTools_TemporaryKey.pfx" />
<None Include="RCS_Clearing_TemporaryKey.pfx" />
<None Include="ThisAddIn.Designer.xml">
Expand Down
Loading

0 comments on commit be3e9df

Please sign in to comment.