View | Details | Raw Unified | Return to bug 44055
Collapse All | Expand All

(-)C:/eclipse/workspace/POI/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java (-2 / +21 lines)
Lines 48-62 Link Here
48
	
48
	
49
	
49
	
50
	/**
50
	/**
51
	 * Constructor for reading MSG Files.
51
	 * Constructor for reading MSG Files from the file system.
52
	 * @param filename
52
	 * @param filename
53
	 * @throws IOException
53
	 * @throws IOException
54
	 */
54
	 */
55
	public MAPIMessage(String filename) throws IOException {
55
	public MAPIMessage(String filename) throws IOException {
56
		InputStream in = new FileInputStream(new File(filename));
56
		this(new FileInputStream(new File(filename)));
57
	}
58
	
59
	/**
60
	 * Constructor for reading MSG Files from an input stream.
61
	 * @param in
62
	 * @throws IOException
63
	 */
64
	public MAPIMessage(InputStream in) throws IOException {
57
		this.fs = new POIFSFileSystem(in);
65
		this.fs = new POIFSFileSystem(in);
58
		chunkParser = new POIFSChunkParser(this.fs);
66
		chunkParser = new POIFSChunkParser(this.fs);
59
	}
67
	}
68
	
60
69
61
	/**
70
	/**
62
	 * Gets a string value based on the passed chunk.
71
	 * Gets a string value based on the passed chunk.
Lines 102-107 Link Here
102
	}
111
	}
103
	
112
	
104
	/**
113
	/**
114
	 * Gets the display value of the "FROM" line of the outlook message
115
	 * This is not the actual address that was sent from but the formated display of the user name.
116
	 * @return
117
	 * @throws ChunkNotFoundException
118
	 */
119
	public String getDisplayFrom() throws ChunkNotFoundException {
120
		return getStringFromChunk(Chunks.getInstance().displayFromChunk);
121
	}
122
	
123
	/**
105
	 * Gets the display value of the "TO" line of the outlook message
124
	 * Gets the display value of the "TO" line of the outlook message
106
	 * This is not the actual list of addresses/values that will be sent to if you click Reply in the email.
125
	 * This is not the actual list of addresses/values that will be sent to if you click Reply in the email.
107
	 * @return
126
	 * @return
(-)C:/eclipse/workspace/POI/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java (+1 lines)
Lines 29-34 Link Here
29
	public StringChunk textBodyChunk = new StringChunk(0x1000);		//BODY Chunk, for plain/text messages
29
	public StringChunk textBodyChunk = new StringChunk(0x1000);		//BODY Chunk, for plain/text messages
30
	public StringChunk subjectChunk = new StringChunk(0x0037);  	//Subject link chunk, in plain/text
30
	public StringChunk subjectChunk = new StringChunk(0x0037);  	//Subject link chunk, in plain/text
31
	public StringChunk displayToChunk = new StringChunk(0x0E04);	//Value that is in the TO field (not actually the addresses as they are stored in recip directory nodes
31
	public StringChunk displayToChunk = new StringChunk(0x0E04);	//Value that is in the TO field (not actually the addresses as they are stored in recip directory nodes
32
	public StringChunk displayFromChunk = new StringChunk(0x0C1A);	//Value that is in the FROM field
32
	public StringChunk displayCCChunk = new StringChunk(0x0E03);	//value that shows in the CC field
33
	public StringChunk displayCCChunk = new StringChunk(0x0E03);	//value that shows in the CC field
33
	public StringChunk displayBCCChunk = new StringChunk(0x0E02);	//Value that shows in the BCC field
34
	public StringChunk displayBCCChunk = new StringChunk(0x0E02);	//Value that shows in the BCC field
34
	public StringChunk conversationTopic = new StringChunk(0x0070); //Sort of like the subject line, but without the RE: and FWD: parts.
35
	public StringChunk conversationTopic = new StringChunk(0x0070); //Sort of like the subject line, but without the RE: and FWD: parts.
(-)C:/eclipse/workspace/POI/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java (+15 lines)
Lines 84-89 Link Here
84
	}
84
	}
85
	
85
	
86
	/**
86
	/**
87
	 * Test to see if we can read the FROM Chunk.
88
	 * @throws ChunkNotFoundException 
89
	 * 
90
	 */
91
	public void testReadDisplayFrom() throws ChunkNotFoundException {
92
		try {
93
			mapiMessage.getDisplayFrom();		
94
		} catch(ChunkNotFoundException exp) {
95
			return;
96
		}
97
		
98
		TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
99
	}
100
	
101
	/**
87
	 * Test to see if we can read the CC Chunk.
102
	 * Test to see if we can read the CC Chunk.
88
	 * @throws ChunkNotFoundException 
103
	 * @throws ChunkNotFoundException 
89
	 * 
104
	 * 
(-)C:/eclipse/workspace/POI/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java (+12 lines)
Lines 67-72 Link Here
67
	}
67
	}
68
	
68
	
69
	/**
69
	/**
70
	 * Test to see if we can read the From Chunk.
71
	 * @throws ChunkNotFoundException 
72
	 * 
73
	 */
74
	public void testReadDisplayFrom() throws ChunkNotFoundException {
75
		String obtained = mapiMessage.getDisplayFrom();
76
		String expected = "Travis Ferguson";
77
		
78
		TestCase.assertEquals(obtained, expected);
79
	}
80
	
81
	/**
70
	 * Test to see if we can read the CC Chunk.
82
	 * Test to see if we can read the CC Chunk.
71
	 * @throws ChunkNotFoundException 
83
	 * @throws ChunkNotFoundException 
72
	 * 
84
	 * 

Return to bug 44055