POP and SMTP assistance

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

POP and SMTP assistance

Stephen Woolerton
Hi there,

I'm trying to get POP and SMTP working.

I've got two POP tests here. One in which I copied the POP example in
the POP.st code and then added a namespace so it would run;  (called
pop.st). For the second test (pop2.st), it looked like the example code
is a class method so I tried calling it.
After the POP test, there is an SMTP test.

I tried installing GNU-Smalltalk on another machine and got the same
result. Since none of my tests work!, I'm hoping someone can show me
what I've done wrong.

I've copied the smalltalk code and excution results below (real
username, password, and hostname modfied to present on web)

Thank you

Code below....

~/projects_smalltalk $ cat pop.st

Smalltalk addSubspace: #NetClients!
"Namespace current: NetClients!"
     | client host username password popClient|
     host := 'server.fqdn'.
     username := 'mailacct'.
     password := 'mailacctpassword'.
     "popClient := POPClient new."
     client := POPClient connectToHost: host.
     [client
         username: username
         password: password.

         client login.
         Transcript showCr: 'New messages: ', client newMessagesCount
printString.
         Transcript showCr: 'bytes ', client newMessagesSize printString.
         Transcript showCr: 'ids ', client newMessagesIds printString.
         Transcript showCr: 'sizes ', client newMessages printString.

         client
             getNewMailMessages: [:m | m inspect]
             delete: false
     ] ensure: [client close] ! !


  ~/projects_smalltalk $ gst pop.st
Object: nil error: did not understand #connectToHost:
MessageNotUnderstood(Exception)>>#signal
UndefinedObject(Object)>>#doesNotUnderstand:
UndefinedObject>>#executeStatements

----------------------

  ~/projects_smalltalk $ cat pop2.st
Smalltalk addSubspace: #NetClients!
"Namespace current: NetClients!"
     | client host username password popClient|
     host := 'server.fqdn'.
     username := 'mailacct'.
     password := 'mailacctpassword'.
     "popClient := POPClient new."
     POPClient exampleHost: host username: username password: password.


  ~/projects_smalltalk $ gst pop2.st
Object: nil error: did not understand #exampleHost:username:password:
MessageNotUnderstood(Exception)>>#signal
UndefinedObject(Object)>>#doesNotUnderstand:
UndefinedObject>>#executeStatements

----------------------

  ~/projects_smalltalk $ cat smtp.st

     "user := '%1@%2' bindWithArguments: { Smalltalk getenv: 'USER'.
        IPAddress localHostName }."

Smalltalk addSubspace: #NetClients!
Namespace current: NetClients!
     | user message client host |

         user := '[hidden email]'.
         host := 'server.fqdn'.
     message := MimeEntity readFrom:
('From: ', user, '
To: ', user, '
To: foo', user, '
Bcc: ', user, '
Subject: Test mail from Smalltalk (SMTPClient)

This is a test mail from Smalltalk (SMTPClient).
') readStream.

     client := SMTPClient connectToHost: host.
     [client sendMessage: message]
         ensure: [client close].!

  ~/projects_smalltalk $ gst smtp.st
Object: nil error: did not understand #readFrom:
Smalltalk.MessageNotUnderstood(Smalltalk.Exception)>>#signal
Smalltalk.UndefinedObject(Smalltalk.Object)>>#doesNotUnderstand:
Smalltalk.UndefinedObject>>#executeStatements


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

S11001001
Stephen Woolerton wrote:

> ~/projects_smalltalk $ cat pop.st
>
> Smalltalk addSubspace: #NetClients!
> "Namespace current: NetClients!"
>     | client host username password popClient|
>     host := 'server.fqdn'.
>     username := 'mailacct'.
>     password := 'mailacctpassword'.
>     "popClient := POPClient new."
>     client := POPClient connectToHost: host.
 > ...
>  ~/projects_smalltalk $ gst pop.st
> Object: nil error: did not understand #connectToHost:

POP and SMTP are in the NetClients package; I suggest you read up on
packages in the manual, chapter 3 "Packages".

Do not load the .st files included with GST manually; they are all in
packages.  You can load NetClients with PackageLoader fileInPackages:
#('NetClients')!

--
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
But you know how reluctant paranormal phenomena are to reveal
themselves when skeptics are present. --Robert Sheaffer, SkI 9/2003


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

Stephen-71

>
> In this case, it's because your code is in the Smalltalk namespace,
> whereas POPClient is in Smalltalk.NetClients.  You should refer to it by
> qualifying it with the namespace, like NetClients.POPClient.
Aha - found the problem. It is actually NetClients.POP.POPClient
>
> If you are compiling methods of a class, you can also "import" all
> NetClients names for use in those methods by adding the namespace to
> "poolDictionaries".  
So thats what that is for. Thanks.

> Note that, as with Common Lisp, the namespace
> system is separate from the package loading system, so you still need to
> load the package.  
That is a key statement... I don't think I've seen that in the docs or
at least not as clear as you've said it.

The code is running now, however I'm getting an error on output when
there are new messages. Error text is below and it refers to a
tokensBaseOn call. I assume I have to load another Package... can you
tell me how I would find what package to add in (so that I know what to
do next time this happens).

Thanks
Stephen

Relevant info below...


In the MIME.st class, there is this method
--------
version: string

     | arr |
     arr := string tokensBasedOn: $..
     arr size < 2 ifTrue: [ self notify: 'Version should be specified as
<major version>.<minor version>' ].
     self majorVersion: arr first.
     self minorVersion: arr last.! !
--------


Here is the output of the script running
---------------------------------------
~/projects_smalltalk $ gst -i pop1.st
"Global garbage collection... done"
Loading package TCP
Loading package SUnit
SUnitTest->14 run, 14 passed, 0 failed, 0 errors
TestSuitesScriptTest->10 run, 10 passed, 0 failed, 0 errors
Loading package NetClients
Recompiling classes...
New messages: 2
bytes 3240
ids (1 2 )
sizes LookupTable (
         1->1620
         2->1620
)
Object: '1.0' error: did not understand #tokensBasedOn:
MessageNotUnderstood(Exception)>>#signal
String(Object)>>#doesNotUnderstand:
NetClients.MIME.VersionField>>#version:
NetClients.MIME.VersionField>>#value:
NetClients.MIME.VersionField(NetClients.MIME.ScalarField)>>#parse:
NetClients.MIME.VersionField(NetClients.MIME.HeaderField)>>#readFrom:
NetClients.MIME.HeaderField class>>#readFrom:
NetClients.MIME.MimeEntity>>#parseFieldFrom:
NetClients.MIME.MimeEntity>>#parseFieldsFrom:
NetClients.MIME.MimeEntity>>#readFrom:
NetClients.MIME.MimeEntity class>>#readFrom:
NetClients.MIME.MimeEntity class(NetClients.MIME.MessageElement
class)>>#readFromClient:
NetClients.POP.POPProtocolInterpreter>>#popRetrieve:
NetClients.POP.POPClient>>#getNewMailMessages:delete:
[] in UndefinedObject>>#executeStatements
BlockClosure>>#ensure:
UndefinedObject>>#executeStatements
Object: POPProtocolInterpreter new "<-0x4c2b8560>" error: Protocol
error: [hidden email]
NetClients.ProtocolError(Exception)>>#signal
NetClients.ProtocolError(Exception)>>#signal:
NetClients.POP.POPProtocolInterpreter(NetClients.NetProtocolInterpreter)>>#protocolError:
[] in NetClients.POP.POPProtocolInterpreter>>#checkResponse:
NetClients.POP.POPProtocolInterpreter>>#checkResponse:ifError:
NetClients.POP.POPProtocolInterpreter>>#checkResponse:
NetClients.POP.POPProtocolInterpreter(NetClients.NetProtocolInterpreter)>>#checkResponse
NetClients.POP.POPProtocolInterpreter>>#popQuit
NetClients.POP.POPClient>>#logout
NetClients.POP.POPClient(NetClients.NetClient)>>#close
[] in UndefinedObject>>#executeStatements<disabled>
BlockClosure>>#ensure:

---------------------------------------

Here is the code I ran...
---------------------------------------
stephenw@duey ~/projects_smalltalk $ cat pop1.st
"NetClients.POP.POPClient exampleHost: ... etc."

PackageLoader fileInPackages: #('NetClients')!
Smalltalk addSubspace: #NetClients!
#Namespace current: NetClients!

     | client host username password popClient|
     host := 'host.fqdn'.
     username := 'mailacct'.
     password := 'mailacctPW'.
     client := NetClients.POP.POPClient connectToHost: host.
     [client
         username: username
         password: password.

         client login.
         Transcript showCr: 'New messages: ', client newMessagesCount
printString.
         Transcript showCr: 'bytes ', client newMessagesSize printString.
         Transcript showCr: 'ids ', client newMessagesIds printString.
         Transcript showCr: 'sizes ', client newMessages printString.

         client
             getNewMailMessages: [:m | m inspect]
             delete: false
     ] ensure: [client close] ! !



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

S11001001
Stephen wrote:
>> If you are compiling methods of a class, you can also "import" all
>> NetClients names for use in those methods by adding the namespace to
>> "poolDictionaries".  
> So thats what that is for. Thanks.

You may also put in any Dictionary with a name that uses Associations
internally.  See the class comments of Dictionary and LookupTable for an
explanation.  In fact, namespaces are just such dictionaries, and pool
dictionaries existed long before namespaces.

> The code is running now, however I'm getting an error on output when
> there are new messages. Error text is below and it refers to a
> tokensBaseOn call. I assume I have to load another Package... can you
> tell me how I would find what package to add in (so that I know what to
> do next time this happens).

I believe this is actually a bug; tokens were removed from the kernel
some time ago, as the ANSI #subStrings: method suffices.  Please replace
"tokensBasedOn:" with "subStrings:" and let us know whether it worked.

--
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
But you know how reluctant paranormal phenomena are to reveal
themselves when skeptics are present. --Robert Sheaffer, SkI 9/2003


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

[patch] explain that namespaces and packages aren't related

S11001001
In reply to this post by Stephen-71
Stephen wrote:
>> Note that, as with Common Lisp, the namespace
>> system is separate from the package loading system, so you still need to
>> load the package.  
> That is a key statement... I don't think I've seen that in the docs or
> at least not as clear as you've said it.

smalltalk--backstage--2.2--patch-56 also attached.

I'm not sure that saying it explicitly won't just encourage the
unfortunate mental conflation of package loading and namespaces brought
on by practice in certain other programming environments, though, so I
may not be in favor of this patch.

--
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
But you know how reluctant paranormal phenomena are to reveal
themselves when skeptics are present. --Robert Sheaffer, SkI 9/2003

2007-09-04  Stephen Compall  <[hidden email]>

        * doc/gst.texi: Explain that namespaces and packages are not
        related in the namespace documentation.

--- orig/doc/gst.texi
+++ mod/doc/gst.texi
@@ -1215,6 +1215,11 @@
     Namespace current: Smalltalk!
 @end example
 
+Loading a package, even with a @samp{namespace} option, will not
+``import'' the namespace; you must still refer to variables in the
+package as if you had simply filed in the code while in that namespace.
+Namespaces and packages are not related.
+
 Also remember that pool dictionaries are actually ``pool namespaces'',
 in the sense that including a namespace in a pool dictionaries list will
 automatically include its superspaces too. Declaring a namespace as a




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [patch] explain that namespaces and packages aren't related

Stephen-71

Stephen Compall wrote:

> Stephen wrote:
>>> Note that, as with Common Lisp, the namespace
>>> system is separate from the package loading system, so you still need to
>>> load the package.  
>> That is a key statement... I don't think I've seen that in the docs or
>> at least not as clear as you've said it.
>
> smalltalk--backstage--2.2--patch-56 also attached.
>
> I'm not sure that saying it explicitly won't just encourage the
> unfortunate mental conflation of package loading and namespaces brought
> on by practice in certain other programming environments, though, so I
> may not be in favor of this patch.
>

Coming into Gnu-smalltalk from java/C++/ruby I was expecting a single
statement would reference (and load) the correct package. So for me at
least, your patch is helpful to identify that packages and namespaces
are different.
I can see why the two are different when I look at the history of
Smalltalk, but it does seem to add complexity compared to
namespaces/packages in other languages.

As an aside: looking in packages.xml was helpful - I was wanting an
overview of where the packages are and what is available. Its all there.


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

Paolo Bonzini
In reply to this post by Stephen-71
> In the MIME.st class, there is this method
> --------
> version: string
>
>     | arr |
>     arr := string tokensBasedOn: $..

Replace it with subStrings:.  I will shortly commit a fix.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

Stephen-71
In reply to this post by S11001001
>
> I believe this is actually a bug; tokens were removed from the kernel
> some time ago, as the ANSI #subStrings: method suffices.  Please replace
> "tokensBasedOn:" with "subStrings:" and let us know whether it worked.
>

Replaced the line in MIME.st as shown.
     | arr |
     arr := string subStrings: $..

I'm running Gnu-Smalltalk 2.3.3, if you need me to install the latest
version I can. (2.3.3. is packaged with Gentoo Linux so that is why I'm
on 2.3.3)


I got this error output after updating MIME.st and running the program
again. Is the problem something that is obvious?

Thanks


~/projects_smalltalk $ gst pop1.st
Loading package TCP
Loading package SUnit
SUnitTest->14 run, 14 passed, 0 failed, 0 errors
TestSuitesScriptTest->10 run, 10 passed, 0 failed, 0 errors
Loading package NetClients
Recompiling classes...
New messages: 2
bytes 3240
ids (1 2 )
sizes LookupTable (
         1->1620
         2->1620
)
Object: RemoveDotStream new "<-0x4c6217d0>" error: Invalid argument -2:
must be positive
SystemExceptions.InvalidArgument(Exception)>>#signal
SystemExceptions.InvalidArgument(Exception)>>#signal:
SystemExceptions.InvalidArgument class(SystemExceptions.InvalidValue
class)>>#signalOn:reason:
NetClients.RemoveDotStream(Stream)>>#skip:
NetClients.MIME.MimeScanner(NetClients.MIME.SimpleScanner)>>#skip:
NetClients.MIME.MimeScanner>>#scanToBoundary:
NetClients.MIME.MimeEntity>>#parseMultipartBodyFrom:
NetClients.MIME.MimeEntity>>#parseBodyFrom:
NetClients.MIME.MimeEntity>>#readFrom:
NetClients.MIME.MimeEntity class>>#readFrom:
NetClients.MIME.MimeEntity class(NetClients.MIME.MessageElement
class)>>#readFromClient:
NetClients.POP.POPProtocolInterpreter>>#popRetrieve:
NetClients.POP.POPClient>>#getNewMailMessages:delete:
[] in UndefinedObject>>#executeStatements
BlockClosure>>#ensure:
UndefinedObject>>#executeStatements
Object: POPProtocolInterpreter new "<-0x4c624248>" error: Protocol
error: format=flowed
NetClients.ProtocolError(Exception)>>#signal
NetClients.ProtocolError(Exception)>>#signal:
NetClients.POP.POPProtocolInterpreter(NetClients.NetProtocolInterpreter)>>#protocolError:
[] in NetClients.POP.POPProtocolInterpreter>>#checkResponse:
NetClients.POP.POPProtocolInterpreter>>#checkResponse:ifError:
NetClients.POP.POPProtocolInterpreter>>#checkResponse:
NetClients.POP.POPProtocolInterpreter(NetClients.NetProtocolInterpreter)>>#checkResponse
NetClients.POP.POPProtocolInterpreter>>#popQuit
NetClients.POP.POPClient>>#logout
NetClients.POP.POPClient(NetClients.NetClient)>>#close
[] in UndefinedObject>>#executeStatements<disabled>
BlockClosure>>#ensure:


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [patch] explain that namespaces and packages aren't related

Paolo Bonzini
In reply to this post by S11001001
Stephen Compall wrote:

> Stephen wrote:
>>> Note that, as with Common Lisp, the namespace
>>> system is separate from the package loading system, so you still need to
>>> load the package.  
>> That is a key statement... I don't think I've seen that in the docs or
>> at least not as clear as you've said it.
>
> smalltalk--backstage--2.2--patch-56 also attached.
>
> I'm not sure that saying it explicitly won't just encourage the
> unfortunate mental conflation of package loading and namespaces brought
> on by practice in certain other programming environments, though, so I
> may not be in favor of this patch.
I'm committing this instead.

Paolo

* auto-adding [hidden email]--2004b/smalltalk--devo--2.2--patch-542 to greedy revision library /Users/bonzinip/Archives/revlib
* found immediate ancestor revision in library ([hidden email]--2004b/smalltalk--devo--2.2--patch-541)
* patching for this revision ([hidden email]--2004b/smalltalk--devo--2.2--patch-542)
--- orig/doc/gst.texi
+++ mod/doc/gst.texi
@@ -63,7 +63,7 @@
 @end direntry
 
 @copying
-This file documents @sc{gnu} Smalltalk Version @value{VERSION}.
+This file documents @sc{gnu} Smalltalk version @value{VERSION}.
 It was last updated on @value{UPDATED}.
 
 Copyright @copyright{} 1988, 1989, 1991, 1992, 1994, 1995, 1999,
@@ -1082,41 +1082,24 @@ of the object, navigating from the tree
 through the tree of sub-environments.
 
 For the identification of global objects in another environment, we use
-a ``pathname'' of symbols.  The symbols are separated by blanks; the
+a ``pathname'' of symbols.  The symbols are separated by periods; the
 ``look'' to appear is that of
 @example
-Smalltalk Tasks MyTask
+Smalltalk.Tasks.MyTask
 @end example
 
 @noindent
 and of
 @example
-Super Super Peter.
+Super.Super.Peter.
 @end example
 
-@noindent
-Its similarity to a sequence of message sends is not casual, and
-suggests the following syntax for write access:
-@example
-Smalltalk Tasks MyTask: anotherTask
-@end example
-
-This resembles the way accessors are used for other objects.  As is
-custom in Smalltalk, however, we are reminded by capitalization that
-we are accessing global objects.
-
-So a variable with an environment path may be resolved to a binding when
-code is compiled, rather than at runtime through a sequence of message
-sends like the above, two special syntaxes have been implemented.
-Standard dot notation can be used to read the value of a global (like in
-@code{Tasks.MyTask} or @code{Tasks::MyTask}), unless you try really hard
-to dissociate variable references between compile time and run time.
-
-Another syntax returns the @dfn{variable binding}, the
-@code{Association} for a particular global.  The last example above is
-equivalently:
+As is custom in Smalltalk, we are reminded by capitalization that we
+are accessing global objects.  Another syntax returns the @dfn{variable
+binding}, the @code{Association} for a particular global.  The first
+example above is equivalently:
 @example
-#@{Smalltalk.Tasks.MyTask@} value: anotherTask
+#@{Smalltalk.Tasks.MyTask@} value
 @end example
 
 The latter syntax, a @dfn{variable binding}, is also valid inside
@@ -1127,7 +1110,7 @@ literal arrays.
 A superclass of @code{SystemDictionary} called @code{RootNamespace} is
 defined, and many of the features of the Smalltalk-80
 @code{SystemDictionary} will be hosted by that class.  @code{Namespace}
-and @code{RootNamespace} will in turn become subclasses of
+and @code{RootNamespace} are in turn subclasses of
 @code{AbstractNamespace}.
 
 To handle inheritance, the following methods have to be defined or redefined in
@@ -1148,17 +1131,12 @@ super-environment if that is the relevan
 @item Enumerators like @code{#do:} and @code{#keys}
 This should return @strong{all} the objects in the namespace, including
 those which are inherited.
-@end table
 
-For programs to be able to process correctly the ``pathnames'' and the
-accessors, this feature should be implemented directly in
-@code{AbstractNamespace}; it is easily handled through the standard
-@code{doesNotUnderstand:} message for trapping message sends that the
-virtual machine could not resolve.  In @gst{}, this is in fact how it is
-done, though the method is part of class @code{BindingDictionary}
-instead.  @code{AbstractNamespace} will also implement a new set of
+@item Hierarchy access
+@code{AbstractNamespace} will also implement a new set of
 methods that allow one to navigate through the namespace hierarchy;
 these parallel those found in @code{Behavior} for the class hierarchy.
+@end table
 
 The most important task of the @code{Namespace} class is to provide
 organization for the most important global objects in the Smalltalk
@@ -1207,31 +1185,39 @@ environment by any other sensibility is
 
 Using namespaces is often merely a matter of adding a @samp{namespace}
 option to the @gst{} @acronym{XML} package description used by
-@code{PackageLoader}, or rewriting the loading script this way:
+@code{PackageLoader}, or wrapping your code like this:
 @example
-    Smalltalk addSubspace: #NewNS!
-    Namespace current: NewNS!
-    @dots{}
-    Namespace current: Smalltalk!
+    Namespace current: NewNS [
+        @dots{}
+    ]
+@end example
+
+Namespaces can be imported into classes like this:
+@example
+    Stream subclass: EncodedStream [
+        <import: Encoders>
+    ]
 @end example
 
-Also remember that pool dictionaries are actually ``pool namespaces'',
-in the sense that including a namespace in a pool dictionaries list will
-automatically include its superspaces too. Declaring a namespace as a
-pool dictionary for a class is similar in this way to C++'s @code{using
-namespace} declaration within the class proper's definition.
+@noindent
+Alternatively, paths to
+classes (and other objects) in the namespaces will have to be specified
+completely.  Importing a namespace into a class is similar to C++'s
+@code{using namespace} declaration within the class proper's definition.
 
 Finally, be careful when working with fundamental system classes.  Although you
 can use code like
 @example
-    Smalltalk Set variableSubclass: #Set
-        @dots{}
-        category: 'My application-Extensions'
-
+    Namespace current: NewNS [
+        Smalltalk.Set subclass: #Set [
+            <category: 'My application-Extensions'>
+            @dots{}
+        ]
+    ]
 @end example
 
 @noindent
-or the equivalent syntax @code{Set extend}, this approach won't work
+this approach won't work
 when applied to core classes.  For example, you might be successful with
 a @code{Set} or @code{WriteStream} object, but subclassing
 @code{SmallInteger} this way can bite you in strange ways: integer
@@ -1239,21 +1225,21 @@ literals will still belong to the @code{
 of the class (this holds for @code{Array}s, @code{String}s, etc.@: too),
 primitive operations will still answer standard Smalltalk
 @code{SmallIntegers}, and so on.  Similarly,
-@code{variableWordSubclasses} will recognize 32-bit @code{Smalltalk
-LargeInteger} objects, but not @code{LargeInteger}s belonging to your
-own namespace.
+word-shaped will recognize 32-bit @code{Smalltalk.LargeInteger} objects,
+but not @code{LargeInteger}s belonging to your own namespace.
 
 Unfortunately, this problem is not easy to solve since Smalltalk has to
-cache the @acronym{OOP}s of determinate class objects for speed---it
+know the @acronym{OOP}s of determinate class objects for speed---it
 would not be feasible to lookup the environment to which sender of a
 message belongs every time the @code{+} message was sent to an Integer.
 
 So, @gst{} namespaces cannot yet solve 100% of the problem of clashes
 between extensions to a class---for that you'll still have to rely on
 prefixes to method names.  But they @emph{do} solve the problem of clashes
-between class names, or between class names and pool dictionary names, so you
-might want to give them a try.  An example of using namespaces is given by
-@file{examples/Publish.st} in the @gst{} source code directory.
+between class names, or between class names and pool dictionary names.
+
+Namespaces are unrelated from packages; loading a package does not
+import the corresponding namespace.
 
 
 @node Disk file-IO
@@ -3252,9 +3238,9 @@ the @code{value} message, and change the
 
 @code{replaceWith:} @code{aString} replaces the string the instance
 points to with the new string.  Actually, it copies the bytes from the
-Smalltalk String instance aString into the C string object, and null
+Smalltalk @code{String} instance aString into the C string object, and null
 terminates.  Be sure that the C string has enough room!  You can also
-use a Smalltalk ByteArray as the data source.
+use a Smalltalk @code{ByteArray} as the data source.
 
 Non-scalars include instances of @code{CArray}, @code{CPtr} and
 subclasses of @code{CStruct} and @code{CUnion}.
@@ -3265,7 +3251,7 @@ CPtrs and CArrays get their underlying e
 
 CPtr's also have @code{value} and @code{value:} which get or change the
 underlying value that's pointed to.  In practice, @code{value} dereferences
-the pointer.  CString is a subclass that answers a Smalltalk String when
+the pointer.  CString is a subclass that answers a Smalltalk @coded{String} when
 sent @code{value}, and automatically allocates storage to copy and
 null-terminate a Smalltalk @code{String} when sent @code{value:}.
 
@@ -3563,8 +3549,8 @@ functions all @dfn{end} with @code{ToOOP
 @code{cObjectToTypedOOP}:
 
 @deftypefun OOP intToOOP (long)
-This object returns a Smalltalk Integer which contains the same value as
-the passed C @code{long}.  Note that Smalltalk Integers are always
+This object returns a Smalltalk @code{Integer} which contains the same value as
+the passed C @code{long}.  Note that Smalltalk integers are always
 signed and have a bit less of precision with respect to C longs.  On 32
 bit machines, their precision is 30 bits (if unsigned) or 31 bits (if
 signed); on 64 bit machines, their precision is 62 bits (if unsigned) or
@@ -3579,32 +3565,32 @@ since the call to @code{OOPToId}.
 @end deftypefun
 
 @deftypefun OOP floatToOOP (double)
-This object returns a Smalltalk FloatD which contains the same value as
+This object returns a Smalltalk @code{FloatD} which contains the same value as
 the passed @code{double}.  Unlike Integers, FloatDs have exactly the same
 precision as C doubles.
 @end deftypefun
 
 @deftypefun OOP longDoubleToOOP (long double)
-This object returns a Smalltalk FloatQ which contains the same value as
+This object returns a Smalltalk @code{FloatQ} which contains the same value as
 the passed @code{long double}.  Unlike Integers, FloatQs have exactly the same
 precision as C long doubles.
 @end deftypefun
 
 @deftypefun OOP boolToOOP (int)
-This object returns a Smalltalk Boolean which contains the same boolean
+This object returns a Smalltalk @code{Boolean} which contains the same boolean
 value as the passed C @code{int}.  That is, the returned OOP is the sole
 instance of either @code{False} or @code{True}, depending on where the
 parameter is zero or not.
 @end deftypefun
 
 @deftypefun OOP charToOOP (char)
-This object returns a Smalltalk Character which represents the same char
+This object returns a Smalltalk @code{Character} which represents the same char
 as the passed C @code{char}.
 @end deftypefun
 
 @deftypefun OOP charToOOP (wchar_t)
-This object returns a Smalltalk Character which represents the same char
-as the passed C @code{wchar_t}.
+This object returns a Smalltalk @code{Character} or @code{UnicodeCharacter}
+which represents the same char as the passed C @code{wchar_t}.
 @end deftypefun
 
 @deftypefun OOP classNameToOOP (char *)

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

Paolo Bonzini
In reply to this post by Stephen-71

> I got this error output after updating MIME.st and running the program
> again. Is the problem something that is obvious?

Yes, the code was tested with MIME messages but not with MIME messages
*read from POP3*.  Sorry.

The attached patch should fix it.

Paolo

2007-09-05  Paolo Bonzini  <[hidden email]>

        * MIME.st: Try not to use negative #skip:.

* looking for [hidden email]--2004b/smalltalk--devo--2.2--patch-545 to compare with
* auto-adding [hidden email]--2004b/smalltalk--devo--2.2--patch-545 to greedy revision library /Users/bonzinip/Archives/revlib
* found immediate ancestor revision in library ([hidden email]--2004b/smalltalk--devo--2.2--patch-544)
* patching for this revision ([hidden email]--2004b/smalltalk--devo--2.2--patch-545)
* comparing to [hidden email]--2004b/smalltalk--devo--2.2--patch-545
M  packages/net/MIME.st

* modified files

--- orig/packages/net/MIME.st
+++ mod/packages/net/MIME.st
@@ -705,8 +705,11 @@ upTo: anObject
     If anObject is not found answer everything."
 
     | str |
-    lookahead isNil ifFalse: [ source skip: -1 ].
+    lookahead = anObject ifTrue: [
+ self sourceTrailNextPut: lookahead.
+ ^'' ].
     str := source upTo: anObject.
+    lookahead isNil ifFalse: [ str := lookahead asString, str ].
     self
  sourceTrailNextPutAll: str;
  sourceTrailNextPut: anObject.
@@ -723,8 +726,8 @@ upToAll: pattern
 
 upToEnd
     | str |
-    lookahead isNil ifFalse: [ source skip: -1 ].
     str := source upToEnd.
+    lookahead isNil ifFalse: [ str := lookahead asString, str ].
     self sourceTrailNextPutAll: str.
     ^str! !
 
@@ -2430,11 +2433,6 @@ decodeUUEncodedFrom: startIndex to: farE
     count := count - 3]]].
     ^data copyFrom: 1 to: output position! !
 
-!MimeScanner methodsFor: 'constants'!
-
-boundaryDashes
-    ^'--'! !
-
 !MimeScanner methodsFor: 'multi-character scans'!
 
 scanText
@@ -2448,13 +2446,12 @@ scanToBoundary: boundary
 " Scan for specified boundary (RFC2046, p5.1). Answer two-element array. First element is the scanned text from current position up to the beginning of the boundary. Second element is either #next or #last. #next means the boundary found is not the last one. #last means the boundary is the closing boundary for the multi-part body (that is, it looks like '--<boundary>--) "
 
     | pattern string kind |
-    pattern := (String with: Character nl), self boundaryDashes , boundary.
+    pattern := (String with: Character nl), '--' , boundary.
     string := self upToAll: pattern.
-    self next: pattern size.                    " Skip over pattern "
-    kind := (self next: 2) = self boundaryDashes
+    kind := (self peekFor: $- and: [ self peekFor: $- ])
  ifTrue: [#last]
- ifFalse:[self skip: -2. #next].
-    self upTo: Character nl.                    " Skip to the end of line "
+ ifFalse:[#next].
+    self upTo: Character nl.
     ^Array with: string with: kind.!
 
 scanToken




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

Paolo Bonzini-2
Paolo Bonzini wrote:
>
>> I got this error output after updating MIME.st and running the program
>> again. Is the problem something that is obvious?
>
> Yes, the code was tested with MIME messages but not with MIME messages
> *read from POP3*.  Sorry.
>
> The attached patch should fix it.

For clarity: I tested this on the latest devo and it worked; I'm now
backporting it.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [patch] explain that namespaces and packages aren't related

S11001001
In reply to this post by Stephen-71
Stephen wrote:
> I can see why the two are different when I look at the history of
> Smalltalk, but it does seem to add complexity compared to
> namespaces/packages in other languages.

Having the rigidity that comes with conflating the at best loosely
related concepts of symbol table partitioning and library loading is
why, for example, class loading in Java servlet containers is so
conceptually complicated.  The designers of the default class loader did
simple, static applications a favor at the expense of more
sophisticated, dynamic designs.

I would like a way to at once communicate the fact that namespaces and
packages are not related, and modify readers' mental model of these
concepts in general so they are less likely to be confused when
encountering such systems in the future.  As a recent GST documentation
reader, do you have any suggestions for how I can modify the paragraph I
posted in the previous patch to achieve this?

--
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
But you know how reluctant paranormal phenomena are to reveal
themselves when skeptics are present. --Robert Sheaffer, SkI 9/2003


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

Stephen-71
In reply to this post by Paolo Bonzini
Hi Paolo

Thank you.

The POP test script is working now for plain text emails. I downloaded
and installed 2.3.6 and ran the POP test script and it works for a plain
text email. If I send it an HTML email then it falls over.

I don't need HTML email for my app but for reference the error is below...
--------------------------

[ projects_smalltalk]$ gst -i pop2.st
"Global garbage collection... done"
Loading package TCP
Loading package SUnit
Loading package NetClients
Recompiling classes...
New messages: 2
bytes 3240
ids (1 2 )
sizes LookupTable (
         1->1620
         2->1620
)
An instance of NetClients.MIME.MimeEntity
   parent: nil
   fields: Dictionary (
         'user-agent'->User-agent:  Thunderbird 2.0.0.6 (Macintosh/20070728)
         'subject'->Subject:  mailping
         'from'->From: emailer name<[hidden email]>
         'mime-version'->Mime-version: 1.0
         'received'->Received:  from mailer.localnet (mailer.localnet
[172.16.3.40]) by mailsvr.acompany.net (Postfix) with ESMTP id
960461E07A9 for <[hidden email]>; Wed,  5 Sep 2007 10:36:19 +1200
(NZST)
         'content-type'->Content-type:  multipart/alternative;
boundary="------------060706090601030305000906"
         'return-path'->Return-path:  <[hidden email]>
         'date'->Date:  Wed, 05 Sep 2007 10:38:02 +1200
         'to'->To: [hidden email]
         'x-sieve'->X-sieve:  CMU Sieve 2.2
         'message-id'->Message-id: <[hidden email]>
)
   body: (Content-transfer-encoding: 7bit
Content-type:  text/plain; charset=ISO-8859-1; format=flowed


--
Regards
emailer name
*Company*

Phone

  Content-transfer-encoding: 7bit
Content-type:  text/html; charset=ISO-8859-1

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<div class="moz-signature">-- <br>
<font face="Helvetica, Arial, sans-serif">Regards<br>
emailer name<br>
<font color="#cc6600"><b>Company</b></font><br>
<font color="#333333"><br>
</font><small><font color="#333333">Phone </font></small></font>
<br>
</div>
</body>
</html>

  )
Object: POPProtocolInterpreter new "<-0x4c03f2a8>" error: Protocol error:
NetClients.ProtocolError(Exception)>>#signal
NetClients.ProtocolError(Exception)>>#signal:
NetClients.POP.POPProtocolInterpreter(NetClients.NetProtocolInterpreter)>>#protocolError:
[] in NetClients.POP.POPProtocolInterpreter>>#checkResponse:
NetClients.POP.POPProtocolInterpreter>>#checkResponse:ifError:
NetClients.POP.POPProtocolInterpreter>>#checkResponse:
NetClients.POP.POPProtocolInterpreter(NetClients.NetProtocolInterpreter)>>#checkResponse
NetClients.POP.POPProtocolInterpreter>>#popRetrieve:
NetClients.POP.POPClient>>#getNewMailMessages:delete:
[] in NetClients.POP.POPClient class>>#exampleHost:username:password:
BlockClosure>>#ensure:
NetClients.POP.POPClient class>>#exampleHost:username:password:
UndefinedObject>>#executeStatements
Object: POPProtocolInterpreter new "<-0x4c03f2a8>" error: Protocol error:
NetClients.ProtocolError(Exception)>>#signal
NetClients.ProtocolError(Exception)>>#signal:
NetClients.POP.POPProtocolInterpreter(NetClients.NetProtocolInterpreter)>>#protocolError:
[] in NetClients.POP.POPProtocolInterpreter>>#checkResponse:
NetClients.POP.POPProtocolInterpreter>>#checkResponse:ifError:
NetClients.POP.POPProtocolInterpreter>>#checkResponse:
NetClients.POP.POPProtocolInterpreter(NetClients.NetProtocolInterpreter)>>#checkResponse
NetClients.POP.POPProtocolInterpreter>>#popQuit
NetClients.POP.POPClient>>#logout
NetClients.POP.POPClient(NetClients.NetClient)>>#close
[] in NetClients.POP.POPClient
class>>#exampleHost:username:password:<disabled>
BlockClosure>>#ensure:



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

Stephen-71
In reply to this post by Paolo Bonzini
Hi Paolo,

I can't get the test smtp script to run. I have checked that a class
method exits on MimeEntity called readFrom (in MIME.st). Would you be
able to see what is wrong with the code below.

Thank you

Here's what happens when I run it...
--------
[ projects_smalltalk]$ gst -i  smtp1.st
"Global garbage collection... done"
Loading package TCP
Loading package SUnit
Loading package NetClients
Recompiling classes...
Object: nil error: did not understand #readFrom:
MessageNotUnderstood(Exception)>>#signal
UndefinedObject(Object)>>#doesNotUnderstand:
UndefinedObject>>#executeStatements

----------

And here is the script

[root@cen5ogo projects_smalltalk]# cat smtp1.st
     "NetClients.SMTP.SMTPClient exampleHost: 'localhost'."
     "user := '%1@%2' bindWithArguments: { Smalltalk getenv: 'USER'.
        IPAddress localHostName }."

PackageLoader fileInPackages: #('NetClients')!
Smalltalk addSubspace: #NetClients!

     | user message client host |

     user := 'mailacct@fqdn'.
     host := 'mailsvr.fqdn'.
     message := MimeEntity readFrom:
('From: ', user, '
To: ', user, '
Subject: Test mail from Smalltalk (SMTPClient)

This is a test mail from Smalltalk (SMTPClient).
') readStream.

     client := NetClients.SMTP.SMTPClient connectToHost: host.
     [client sendMessage: message]
         ensure: [client close].!





_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

S11001001
On Sat, 2007-09-08 at 14:55 +1200, Stephen wrote:
> Object: nil error: did not understand #readFrom:

In general, when you try to send a message to a class that you name in
your code (MimeEntity here), and you get an error that says it is nil,
it means that GST couldn't find such a class in your method's namespace.

> PackageLoader fileInPackages: #('NetClients')!
> Smalltalk addSubspace: #NetClients!

This #addSubspace: send is vacuous.  What are you trying to do here?

--
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
"Peta" is Greek for fifth; a petabyte is 10 to the fifth power, as
well as fifth in line after kilo, mega, giga, and tera.
  -- Lee Gomes, performing every Wednesday in his tech column
     "Portals" on page B1 of The Wall Street Journal

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: POP and SMTP assistance

Stephen-71
Sorry, brain fade.

Should have used NetClients.MIME.MimeEntity.

Stephen




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk